This article introduces how to configure Apache Solr as the full-text search backend for Dovecot. And on top of the recommended Solr configuration, a few tweaks are also applied to improve Chinese, Japanese, Korean, aka. CJK, support.
1. Environment
Ubuntu 18.04 LTS is used in this tutorial and at the time of writing, the latest Dovecot suite in the official repository is 2.2.33.2-1ubuntu4.5
.
2. Prerequisites
3. Solr Configuration
Solr hasn’t got a DEB distribution but it can be easily set up via Docker. Before we fire it up though, a ‘core’ is needed to be created for Dovecot. If you come from a document-oriented database background, a ‘core’ is similar to a collection, but also holds some additional configurations, e.g. schema, language analysis settings and etc.
$ apt-get install dovecot-solr # check out https://github.com/docker-solr/docker-solr/tree/909a2f021231e4fa1a2ef7ea77885b1530f80110 for details $ docker pull solr:7 # currently the suggested version by Dovecot $ mkdir -p /srv/solr # this is where we are going to store the data $ chown 8983:8983 $_ # update UID/GID to make sure Solr can write to it later $ docker run --rm -it -v /srv/solr:/var/solr -e SOLR_HOME=/var/solr -e INIT_SOLR_HOME=yes solr:7 bash # in container $ init-solr-home $ precreate-core dovecot # you can change the core name $ exit # in host $ cd /srv/solr/dovecot/conf $ rm -f schema.xml managed-schema solrconfig.xml