tantivy icon indicating copy to clipboard operation
tantivy copied to clipboard

QueryParser raises SyntaxError when combining field prefix with nested searchstring

Open mrwunderbar666 opened this issue 2 years ago • 1 comments

Describe the bug

  • What did you do?

Given the query (A OR B) NOT (C OR D), I can produce a syntax error, where I believe should be none. These two variations work fine:

let query = query_parser.parse_query("(A OR B) NOT (C OR D)");
let query = query_parser.parse_query("((A OR B) NOT (C OR D))");

Let's say, I search in the field title then these two variations raise syntax errors:

let query = query_parser.parse_query("title:(A OR B) NOT (C OR D)");
// also wrapping the query in additional parentheses doesn't help
let query = query_parser.parse_query("title:((A OR B) NOT (C OR D))");

I would expect that the query parses just fine since this works:

let query = query_parser.parse_query("title:A OR B NOT (C OR D)");

Which version of tantivy are you using? Version 0.22.0 (via cargo)

EDIT:

I've also ran into issues with a query like this one

let query = query_parser.parse_query(r#" "a b" OR "a c"~3 NOT (d AND (e OR f)) "#);

I would propose to add unit tests to the query-grammar

I think my issue is related to this one: #1980

mrwunderbar666 avatar Apr 26 '24 21:04 mrwunderbar666

this seems to work on 0.25.. can probably be closed

flow3d avatar Sep 20 '25 11:09 flow3d