diff options
| author | David Bremner <david@tethera.net> | 2017-02-26 22:34:20 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-03-03 17:46:48 -0400 |
| commit | 55524bb063c95ae51a1762eb0b1aacce6ca49223 (patch) | |
| tree | 06ec5e27a5d20ca917bbff7e9d732ab94cff0fc2 /lib/database.cc | |
| parent | 31b8ce4558de69860c95bf319a0a162316dce6c6 (diff) | |
lib: regexp matching in 'subject' and 'from'
the idea is that you can run
% notmuch search subject:/<your-favourite-regexp>/
% notmuch search from:/<your-favourite-regexp>/
or
% notmuch search subject:"your usual phrase search"
% notmuch search from:"usual phrase search"
This feature is only available with recent Xapian, specifically
support for field processors is needed.
It should work with bindings, since it extends the query parser.
This is easy to extend for other value slots, but currently the only
value slots are date, message_id, from, subject, and last_mod. Date is
already searchable; message_id is left for a followup commit.
This was originally written by Austin Clements, and ported to Xapian
field processors (from Austin's custom query parser) by yours truly.
Diffstat (limited to 'lib/database.cc')
| -rw-r--r-- | lib/database.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/database.cc b/lib/database.cc index fa4c3116..573c9fe0 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -21,6 +21,7 @@ #include "database-private.h" #include "parse-time-vrp.h" #include "query-fp.h" +#include "regexp-fields.h" #include "string-util.h" #include <iostream> @@ -277,7 +278,8 @@ prefix_t prefix_table[] = { NOTMUCH_FIELD_PROCESSOR }, #endif { "from", "XFROM", NOTMUCH_FIELD_EXTERNAL | - NOTMUCH_FIELD_PROBABILISTIC }, + NOTMUCH_FIELD_PROBABILISTIC | + NOTMUCH_FIELD_PROCESSOR }, { "to", "XTO", NOTMUCH_FIELD_EXTERNAL | NOTMUCH_FIELD_PROBABILISTIC }, { "attachment", "XATTACHMENT", NOTMUCH_FIELD_EXTERNAL | @@ -285,7 +287,8 @@ prefix_t prefix_table[] = { { "mimetype", "XMIMETYPE", NOTMUCH_FIELD_EXTERNAL | NOTMUCH_FIELD_PROBABILISTIC }, { "subject", "XSUBJECT", NOTMUCH_FIELD_EXTERNAL | - NOTMUCH_FIELD_PROBABILISTIC }, + NOTMUCH_FIELD_PROBABILISTIC | + NOTMUCH_FIELD_PROCESSOR}, }; static void @@ -309,7 +312,7 @@ _setup_query_field (const prefix_t *prefix, notmuch_database_t *notmuch) else if (STRNCMP_LITERAL(prefix->name, "query") == 0) fp = (new QueryFieldProcessor (*notmuch->query_parser, notmuch))->release (); else - INTERNAL_ERROR("unsupported field processor prefix: %s\n", prefix->name); + fp = (new RegexpFieldProcessor (prefix->name, *notmuch->query_parser, notmuch))->release (); /* we treat all field-processor fields as boolean in order to get the raw input */ notmuch->query_parser->add_boolean_prefix (prefix->name, fp); |
