I am using my own e-mail server for a few years now, but I almost never use search in my mailbox, so I did not really noticed how slow it was. All because the heavy lifting is left to the client to do.
Enter the FTS aka full-text search, a wonderful solution that forces server to do the dirty part, so your phone has more juice for browsing reddit.
My server is based on Dovecot, so first we need to find out what does it support and how can we make it work.
The official installation notes are pretty self explanatory and can be found here
$ apt-get build-dep dovecot-core $ apt-get install dovecot-dev libxapian30
$ git clone https://github.com/grosjo/fts-xapian $ cd fts-xapian
$ autoreconf -vi $ ./configure --with-dovecot=/usr/lib/dovecot $ make $ sudo make install
Add this to the
plugin section of your
### ### fts-xapian - full text search (source in /opt/fts-xapian) ### https://github.com/grosjo/fts-xapian ### plugin = fts fts_xapian fts = xapian fts_xapian = partial=2 full=20 attachments=0 verbose=0 fts_autoindex = yes fts_enforced = yes fts_autoindex_exclude = \Trash
systemctl restart dovecot
Re-index all the mailboxes:
$ doveadm index -A -q \*
You should see the speed increase in seaches immediatly.
If you check the logs, you will see that the indexing is going on as you search.
Aug 18 14:29:30 sablun dovecot: indexer-worker(email@example.com)<2395994><dsnRCSaazv5ejFqk:U6AOAKrJe18SmyQAv0xPeQ>: Indexed 0 messages in Archive Aug 18 14:29:30 sablun dovecot: indexer-worker(firstname.lastname@example.org)<2395994><sZzUCSaay/5ejFqk:GBxIAarJe18SmyQAv0xPeQ>: Indexed 0 messages in INBOX