diff options
| author | David Bremner <david@tethera.net> | 2017-03-17 23:23:51 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-03-24 09:24:13 -0300 |
| commit | 38a56b98f9b282decc5edbe1da9717e3b2bdb6b2 (patch) | |
| tree | 10e566f3d8688f844b8f173cf19376c4e8cfef0f /lib | |
| parent | 497b83780ee50e2cd37f352caa3bd2b6c936dfab (diff) | |
lib: only trigger phrase processing for regexp fields when needed
The argument is that if the string passed to the field processor has
no spaces, then the added quotes won't have any benefit except for
disabling wildcards. But disabling wildcards doesn't seem very useful
in the normal Xapian query parser, since they're stripped before
generating terms anyway. It does mean that the query 'from:"foo*"' will
not be precisely equivalent to 'from:foo' as it is for the non
field-processor version.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/regexp-fields.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc index 8e740a81..9dcf9732 100644 --- a/lib/regexp-fields.cc +++ b/lib/regexp-fields.cc @@ -158,8 +158,14 @@ RegexpFieldProcessor::operator() (const std::string & str) } else { /* TODO replace this with a nicer API level triggering of * phrase parsing, when possible */ - std::string quoted='"' + str + '"'; - return parser.parse_query (quoted, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix); + std::string query_str; + + if (str.find (' ') != std::string::npos) + query_str = '"' + str + '"'; + else + query_str = str; + + return parser.parse_query (query_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix); } } #endif |
