From bd656386b93ef9f4e07dda1d1ea01f9a0b8f103e Mon Sep 17 00:00:00 2001 From: Benedek Nagy Date: Mon, 21 Jul 2025 00:15:46 +0200 Subject: [PATCH] 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 Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/email/__init__.py | 5 +++-- .../dovecot/conf.d/2.3/95-freedombox-fts.conf | 18 +++++++++++++++ .../dovecot/conf.d/2.4/95-freedombox-fts.conf | 22 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.3/95-freedombox-fts.conf create mode 100644 plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.4/95-freedombox-fts.conf diff --git a/plinth/modules/email/__init__.py b/plinth/modules/email/__init__.py index 721976d98..a06a7f2ed 100644 --- a/plinth/modules/email/__init__.py +++ b/plinth/modules/email/__init__.py @@ -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) diff --git a/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.3/95-freedombox-fts.conf b/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.3/95-freedombox-fts.conf new file mode 100644 index 000000000..3f716c2c6 --- /dev/null +++ b/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.3/95-freedombox-fts.conf @@ -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 +} diff --git a/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.4/95-freedombox-fts.conf b/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.4/95-freedombox-fts.conf new file mode 100644 index 000000000..a715c58a4 --- /dev/null +++ b/plinth/modules/email/data/usr/share/freedombox/etc/dovecot/conf.d/2.4/95-freedombox-fts.conf @@ -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 +}