Setting up Solr to improve search performance
While performing IMAP search on just the headers is usually fast, running search in message text in standard setup of MailSuite Pro could use improvement. That's done by setting up and configuring an additional search module, we use Apache Solr for this purpose.
The configuration is performed as follows (with superuser/root privileges):
- Install Dovecot packages:
apt install dovecot-core dovecot-imapd dovecot-lmtpd dovecot-managesieved dovecot-mysql dovecot-pop3d dovecot-sieve dovecot-solr
- Install Java:
apt install default-jre
- Install Solr:
wget https://downloads.apache.org/lucene/solr/8.11.1/solr-8.11.1.tgz
tar xzf solr-8.11.1.tgz solr-8.11.1/bin/install_solr_service.sh --strip-components=2
bash ./install_solr_service.sh solr-8.11.1.tgz
systemctl start solr
- Init Solr schema namespace:
su - solr -c "/opt/solr/bin/solr create -c dovecot -n dovecot"
Solr configuration is found under /var/solr/data/dovecot/conf/
directory:
ls -la /var/solr/data/dovecot/conf/
total 52
drwxr-xr-x 3 solr solr 4096 Oct 7 12:33 .
drwxr-xr-x 4 solr solr 4096 Sep 28 14:55 ..
drwxr-xr-x 2 solr solr 4096 Sep 28 14:21 lang
-rw-r--r-- 1 solr solr 6127 Oct 7 12:33 managed-schema
-rw-r--r-- 1 solr solr 882 Oct 6 12:43 protwords.txt
-rw-r--r-- 1 solr solr 6944 Oct 7 12:33 schema.xml.bak
-rw-r--r-- 1 solr solr 11287 Sep 28 15:00 solrconfig.xml
-rw-r--r-- 1 solr solr 781 Jun 10 20:23 stopwords.txt
-rw-r--r-- 1 solr solr 1124 Jun 10 20:23 synonyms.txt
- Reconfigure Dovecot
In /etc/dovecot/conf.d/10-mail.conf
file, make sure fts and fts_solr are included in list of mail_plugins
:
mail_plugins = $mail_plugins fts fts_solr virtual
Also, add the following section into /etc/dovecot/conf.d/90-plugin.conf file:
plugin {
fts = solr
fts_solr = url=http://127.0.0.1:8983/solr/dovecot/
fts_autoindex = yes
}
- Restart services to apply changes:
service dovecot restart
service solr restart