Full text search with solr and Dovecot on Ubuntu 10.04

It has been just some days that Dovecot 2.1 was released. When upgrading from 2.0 I started digging into a new and interesting chapter: full text search (FTS).

With Apache solr you can use an external service in Dovecot to do FTS. Solr and Dovecot itself is described on the official website http://wiki2.dovecot.org/Plugins/FTS/Solr, so this is just a short version that focuses more on how to achieve the installation process for Ubuntu Lucid Lynx.

I have built dovecot-2.1 packages on my PPA: https://launchpad.net/~christian-roessner-net/+archive/dovecot

After having installed Dovecot, you can simply install solr with apt-get:


apt-get install solr-tomcat

This will install a tomcat application server with solr as application. Now you simply need to replace one xml file:


cp /usr/share/doc/dovecot-common/solr-schema.xml /etc/solr/conf/schema.xml

That is all that needs to be done on solr side. After replacing the file, please start the tomcat service as shown:


/etc/init.d/tomcat6 restart

For Dovecot itself, I modified two files as followed:

/etc/dovecot/conf.d/10-mail.conf:

...
# 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 = quota acl fts fts_solr
...

In my case, I also need quota and acl support, which you do _not_ need for FTS. So leave it away, if you do not want it. It is just here to show how to add plugins.

/etc/dovecot/conf.d/90-plugin.conf

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

The break-imap-search is a good modification (in my opinion). See the wiki documentation for more details.

That is all you need to do. If you use a webmailer like roundcube, you can do a FTS and watch the file /var/log/tomcat6/catalina.out for results. Enjoy 🙂