From e2d9ed153f5b15414fa2bd1c6e7b7e91a3f72046 Mon Sep 17 00:00:00 2001 From: Jonty Wareing Date: Wed, 22 Oct 2014 20:14:05 +0100 Subject: [PATCH] Add support for fast searching via Solr This installs and configures Solr running under Tomcat, and configures Dovecot to use the dovecot-solr plugin for all search and indexing. This dramatically improves search performance on large mailboxes. --- setup/solr.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ setup/start.sh | 1 + 2 files changed, 50 insertions(+) create mode 100644 setup/solr.sh diff --git a/setup/solr.sh b/setup/solr.sh new file mode 100644 index 00000000..ecfb4133 --- /dev/null +++ b/setup/solr.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# IMAP search with lucene via solr +# -------------------------------- +# +# By default dovecot uses its own Squat search index that has awful performance +# on large mailboxes. Dovecot 2.1+ has support for using Lucene internally but +# this didn't make it into the Ubuntu packages, so we use Solr instead to run +# Lucene for us. +# +# Solr runs as a tomcat process. The dovecot solr plugin talks to solr via its +# HTTP interface, causing mail to be indexed when searches occur, and getting +# results back. + +source setup/functions.sh # load our functions +source /etc/mailinabox.conf # load global vars + +# Install packages and basic configuation +# --------------------------------------- + +# Install packages +apt_install solr-tomcat dovecot-solr + +# Solr requires a schema to tell it how to index data, this is provided by dovecot +wget http://hg.dovecot.org/dovecot-2.2/raw-file/e99cd21e1f92/doc/solr-schema.xml \ + -O /etc/solr/conf/schema.xml + +# Update the dovecot plugin configuration +# +# Break-imap-search makes search work the way users expect, rather than the way +# the IMAP specification expects +tools/editconf.py /etc/dovecot/conf.d/10-mail.conf \ + mail_plugins="$mail_plugins fts fts_solr" + +cat > /etc/dovecot/conf.d/90-plugin.conf << EOF; +plugin { + fts = solr + fts_solr = break-imap-search url=http://127.0.0.1:8080/solr/ +} +EOF + +# PERMISSIONS + +# Ensure configuration files are owned by dovecot and not world readable. +chown -R mail:dovecot /etc/dovecot +chmod -R o-rwx /etc/dovecot + +# Restart services to reload solr schema & dovecot plugins +restart_service tomcat6 +restart_service dovecot diff --git a/setup/start.sh b/setup/start.sh index d84669b3..38050966 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -120,6 +120,7 @@ source setup/mail-dovecot.sh source setup/mail-users.sh source setup/dkim.sh source setup/spamassassin.sh +source setup/solr.sh source setup/web.sh source setup/webmail.sh source setup/owncloud.sh