70 lines
2.5 KiB
ReStructuredText
70 lines
2.5 KiB
ReStructuredText
Full text search
|
|
==========================
|
|
|
|
By default, when your IMAP client searches for an email containing some
|
|
text in its *body*, dovecot will read all your email sequentially. This
|
|
is very slow and IO intensive. To speed body searches up, it is possible to
|
|
*index* emails with the ``fts_flatcurve`` dovecot plugin.
|
|
|
|
Enabling full text search
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
To enable indexing for full text search here is an example configuration.
|
|
|
|
.. code:: nix
|
|
|
|
{
|
|
mailserver = {
|
|
# ...
|
|
fullTextSearch = {
|
|
enable = true;
|
|
# index new email as they arrive
|
|
autoIndex = true;
|
|
# only query index
|
|
fallback = false;
|
|
};
|
|
};
|
|
}
|
|
|
|
|
|
Disabling the :option:`mailserver.fullTextSearch.fallback` option tells dovecot
|
|
to fail any body search query that cannot use an index. This prevents Dovecot to
|
|
fall back to the IO-intensive brute force search.
|
|
|
|
If you set :option:`mailserver.fullTextSearch.autoIndex` to ``false``, indices
|
|
will be created when the IMAP client issues a search query, so latency will
|
|
be high.
|
|
|
|
Resource requirements
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Indices created by the full text search feature can take more disk space than
|
|
the emails themselves. By default, they are kept within the maildir. When
|
|
enabling the full text search feature, it is recommended to move indices in a
|
|
different location, such as (``/var/lib/dovecot/indices``) by configuring
|
|
:option:`mailserver.indexDir`.
|
|
|
|
.. warning::
|
|
|
|
When the value of the :option:`mailserver.indexDir` option is changed, all
|
|
dovecot indices needs to be recreated: clients would need to resynchronize.
|
|
|
|
Indexation itself is rather resource intensive, in CPU, and for emails with
|
|
large headers, in memory as well. Initial indexation of existing emails can take
|
|
hours. If the indexer worker is killed or segfaults during indexation, it can be
|
|
that it tried to allocate more memory than allowed. You can increase the default
|
|
memory limit through :option:`mailserver.fullTextSearch.memoryLimit`.
|
|
|
|
Mitigating resources requirements
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
You can:
|
|
|
|
* exclude some headers from indexation with :option:`mailserver.fullTextSearch.headerExcludes`
|
|
* disable expensive token normalisation in :option:`mailserver.fullTextSearch.filters`
|
|
* disable automatic indexation for individual mailboxes by overriding
|
|
`fts_autoindex`_ on the mailbox level. This is exposed via
|
|
:option:`mailserver.mailboxes`, where all default mailboxes are defined.
|
|
|
|
.. _fts_autoindex: https://doc.dovecot.org/main/core/plugins/fts.html#fts_autoindex
|