mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
Add the magic to allow searches such as "tag:inbox".
The key for this is call add_boolean_prefix on the QueryParser object. That tells the query parser to take something like "tag:inbox" and transform it into the "Linbox" term and do what it needs to do to make this term a requirement of the search. We're starting to have a real system here. Also, I didn't want to expose the ugly name of "msgid" to the user, so we add a prefix name of simply "id" instead.
This commit is contained in:
parent
17f9c6a0ef
commit
aa46a683a8
1 changed files with 4 additions and 0 deletions
|
@ -45,6 +45,7 @@ prefix_t BOOLEAN_PREFIX[] = {
|
|||
{ "type", "K" },
|
||||
{ "tag", "L" },
|
||||
{ "msgid", "Q" },
|
||||
{ "id", "Q" },
|
||||
{ "thread", "H" },
|
||||
{ "ref", "R" },
|
||||
{ "timestamp", "KTS" },
|
||||
|
@ -493,6 +494,9 @@ notmuch_database_open (const char *path)
|
|||
notmuch->query_parser = new Xapian::QueryParser;
|
||||
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
|
||||
notmuch->query_parser->set_database (*notmuch->xapian_db);
|
||||
notmuch->query_parser->add_boolean_prefix ("id", _find_prefix ("id"));
|
||||
notmuch->query_parser->add_boolean_prefix ("tag", _find_prefix ("tag"));
|
||||
notmuch->query_parser->add_boolean_prefix ("type", _find_prefix ("type"));
|
||||
} catch (const Xapian::Error &error) {
|
||||
fprintf (stderr, "A Xapian exception occurred: %s\n",
|
||||
error.get_msg().c_str());
|
||||
|
|
Loading…
Reference in a new issue