9.1 Search Engines

In order to search for messages from any given server, that server must have a search engine associated with it. IMAP servers do their own searching, and searching IMAP groups will work with no additional configuration, but in all other cases the user will have to manually specify an engine to use. This can be done at two different levels: by server type, or on a per-server basis.

The option gnus-search-default-engines assigns search engines by server type. Its value is an alist mapping symbols indicating a server type (e.g. nnmaildir or nnml) to symbols indicating a search engine class. The built-in search engine symbols are:

If you need more granularity, you can specify a search engine in the server definition, using the gnus-search-engine key, whether that be in your .gnus.el config file, or through Gnus’ server buffer. That might look like:

'(nnmaildir "My Mail"
   (directory "/home/user/.mail")
   (gnus-search-engine gnus-search-notmuch
     (config-file "/home/user/.mail/.notmuch_config")))

Search engines like notmuch, namazu, mairix and mu are similar in behavior: they use a local executable to create an index of a message store, and run command line search queries against those messages, and return a list of absolute file names of matching messages.

These engines have a handful of configuration parameters in common. These common parameters are:

program

The name of the executable. Defaults to the plain program name such as notmuch or namazu.

config-file

The absolute filename of the configuration file for this search engine.

remove-prefix

The directory part to be removed from the filenames returned by the search query. This absolute path should include everything up to the top level of the message store. Note that this is the path to the location of the actual messages, not to the search engine’s indexes (nor, in the case of Mairix, to its symlink directories).

switches

Additional command-line switches to be fed to the search program. The value of this parameter must be a list of strings, one string per switch.

The options above can be set in one of two ways: using a customization option that is set for all engines of that type, or on a per-engine basis in your server configuration files.

The customization options are formed on the pattern gnus-search-engine-parameter. For instance, to use a non-standard notmuch program, you might set gnus-search-notmuch-program to /usr/local/bin/notmuch. This would apply to all notmuch engines. The engines that use these options are: “notmuch”, “namazu”, “mairix”, “mu”, “swish-e” and “swish++”.

Alternately, the options can be set directly on your Gnus server definitions, for instance, in the nnmaildir example above. Note that the server options are part of the gnus-search-engine sexp, and the option symbol and value form a two-element list, not a cons cell.

The namazu and swish-e engines each have one additional option, specifying where to store their index files. For namazu it is index-directory, and should be a single directory path. For swish-e it is index-files, and should be a list of strings.

All indexed search engines come with their own method of updating their search indexes to include newly-arrived messages. Gnus currently provides no convenient interface for this, and you’ll have to manage updates yourself, though this will likely change in the future.

Lastly, all search engines accept a raw-queries-p option. This indicates that engines of this type (or this particular engine) should always use raw queries, never parsed (see Search Queries).