Friday, May 16, 2014

Installing fast indexed search for IMAP e-mail

With Dovecot and apache SOLR it's possible to install very fast mail search. You can search through the entire message contents within fractions of a second.

I've used Ubuntu and Debian to set this up.

Tomcat SOLR

Install the tomcat solr server with the following command:

$ apt-get install solr-tomcat

Find the SOLR schema on page

Make sure your dovecot version matches.

Download it like this:

$ wget

Move the file to the right location:

$ cp solr-schema.xml /etc/solr/conf/schema.xml

$ service tomcat6 restart

Check if tomcat works by browsing to:



Now setup Dovecot. Modify:


# Space separated list of plugins to load for all services. Plugins specific to
# IMAP, LDA, etc. are added to this list in their own .conf files.
#mail_plugins =
mail_plugins = $mail_plugins fts fts_solr


plugin {
  fts = solr
  fts_solr = break-imap-search url=http://localhost:8080/solr/

The "break-imap-search" option will use Solr also for indexing TEXT and BODY searches. This makes your server non-IMAP-compliant, but it's what people want ;). This is always enabled in v2.1+.

Now when an IMAP client does a "SEARCH TEXT keyword command" you should see these log entries in /var/log/mail.log:

May 15 14:19:29 dovecot: indexer-worker( Indexed 294 messages in INBOX

Enjoy the fast searches!

1 comment:

  1. Is it also possible to search with more than just one keyword?