email: Add full text search capability

Add Full Text Search capability to Dovecot.
- Add 'dovecot-fts-xapian' to the list of packages for the email app.
- Add relevant configs for both dovecot 2.3 and 2.4
- Add a systemd timer to periodically clean search indexes

Configurations taken from plugin's upstream documentation:
https://github.com/grosjo/fts-xapian

Sunil:

- Tweak the dovecot 2.4 configuration. Remove explicit configuration same as or
close to default values.

- Drop the timer service for cleaning up the index. Dovecot documentation that
FTS plugins do it themselves.

- Drop the re-indexing command on setup. This could not be properly tested. On
first search, indexes will be created for mailboxes that don't have them.

Tests done:

- Perform a fresh install, on both Bookworm and Trixie, confirm the install is
successful, confirm the systemd service runs with exit 0.

- On Bookworm, apply the patches on an existing setup, confirm the patches apply
as expected.

- On a production like setup, set dovecot 2.4 to debug mode and check the
journal logs while receiving an email: The logs confirm that the fts module is
loaded and that it automatically creates a db for the indexes. I also opened the
newly created db file with less and confirmed that the human readable parts
contain my recent email.

- Using Sogo, perform a full search (including headers and body). Search works
and indexes are freshly created on all the folders.

Signed-off-by: Benedek Nagy <contact@nbenedek.me>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Benedek Nagy 2025-07-21 00:15:46 +02:00 committed by Sunil Mohan Adapa
parent 7424564074
commit bd656386b9
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 43 additions and 2 deletions

View File

@ -52,7 +52,7 @@ class EmailApp(plinth.app.App):
app_id = 'email'
_version = 7
_version = 8
def __init__(self) -> None:
"""Initialize the email app."""
@ -93,7 +93,7 @@ class EmailApp(plinth.app.App):
'packages-email', [
'postfix', 'postfix-sqlite', 'dovecot-pop3d', 'dovecot-imapd',
'dovecot-lmtpd', 'dovecot-managesieved', 'dovecot-ldap',
'rspamd', 'redis-server', 'openssl'
'dovecot-fts-xapian', 'rspamd', 'redis-server', 'openssl'
], conflicts=['exim4-base', 'exim4-config', 'exim4-daemon-light'],
conflicts_action=Packages.ConflictsAction.REMOVE,
rerun_setup_on_upgrade=True)
@ -127,6 +127,7 @@ class EmailApp(plinth.app.App):
'/etc/dovecot/conf.d/90-freedombox-master.conf',
'/etc/dovecot/conf.d/90-freedombox-tls.conf',
'/etc/dovecot/conf.d/95-freedombox-sieve.conf',
'/etc/dovecot/conf.d/95-freedombox-fts.conf',
'/etc/dovecot/conf.d/freedombox-ldap.conf.ext'
])
self.add(dropin_configs_dovecot)

View File

@ -0,0 +1,18 @@
# Do not edit this file. Manage your settings on FreedomBox.
# Configure full-text search (FTS) for Dovecot.
# https://doc.dovecot.org/2.3/configuration_manual/fts/
# https://github.com/grosjo/fts-xapian
mail_plugins = $mail_plugins fts fts_xapian
plugin {
fts = xapian
fts_autoindex = yes
fts_enforced = yes
}
service indexer-worker {
vsz_limit = 2G
process_limit = 0
}

View File

@ -0,0 +1,22 @@
# Do not edit this file. Manage your settings on FreedomBox.
# Configure full-text search (FTS) for Dovecot.
# https://doc.dovecot.org/2.4.1/core/plugins/fts.html
# https://github.com/grosjo/fts-xapian
mail_plugins {
fts = yes
fts_xapian = yes
}
fts freedombox-xapian {
driver = xapian
autoindex = yes
}
# For dovecot, at least one language must be specified and one single language
# must be flagged as default language. However, this has no impact on FTS Xapian
# module.
language en {
default = yes
}