Strange, incoherent query parsing
David Bremner
david at tethera.net
Thu Aug 29 17:13:17 PDT 2019
Jorge P. de Morais Neto <jorge+list at disroot.org> writes:
> Hello,
>
> Em 2019-08-28T07:08:28-0300, David Bremner escreveu:
>
>> I don't know about the other cases but here there is an extra closing
>> ')', which confuses the query parser. I agree that an error report
>> would be nicer, but we don't currently have that option from Xapian.
>
> Oops. Sorry about that. But still there seem to be real errors. The
> first query[1] should match messages containing both "Saúde" and "Geap"
> (sans the double quotes) in the subject, but does not.
>
> 1: 'subject:("Saúde" "Geap") OR subject:xplitz'
There's two problems here. The first is because of the way regexp fields
are implimented subject: doesn't tolerate the unescaped/unquoted space.
So you'd have to write 'subject:"(Saúde Geap)"' to get anything sensible.
The other problem is that are treating the part within () as a quoted
phrase, which is not correct.
If you can build from source try the patch below [1]. With it, I think
notmuch count 'subject:"(Saúde Geap)" OR subject:xplitz'
should behave more like what you want. Notice my use of quotes is bit
different that your original query.
>
> Also note that the fourth query[2] should have AND as the implicit
> boolean operator, because 'subject:' is not a boolean prefix. You
> explained in the other thread the implicit OR operator only applies for
> search terms with the same /boolean/ prefix.
Yes, this is the same problem as in your other report. I posted some
patches that should fix it, but they need more testing.
[1]:
diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 198eb32f..858b1e24 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -189,6 +189,13 @@ RegexpFieldProcessor::operator() (const std::string & str)
} else {
throw Xapian::QueryParserError ("unmatched regex delimiter in '" + str + "'");
}
+ } else if (str.at (0) == '(') {
+ if (str.length () > 1 && str.at (str.size () - 1) == ')') {
+ std::string subexp_str = str.substr (1, str.size () - 2);
+ return parser.parse_query (subexp_str, NOTMUCH_QUERY_PARSER_FLAGS, term_prefix);
+ } else {
+ throw Xapian::QueryParserError ("unmatched '(' in '" + str + "'");
+ }
} else {
if (options & NOTMUCH_FIELD_PROBABILISTIC) {
/* TODO replace this with a nicer API level triggering of
More information about the notmuch
mailing list