lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <>
Subject Re: Inconsistent parsing of pure negative queries inside brackets
Date Mon, 04 Jul 2016 16:09:42 GMT
On 7/4/2016 7:04 AM, Rahul Verma wrote:
> While tracing a bug in one of our systems we notices some interesting
> behavior from Solr. These two queries return different results. I fail
> to understand why the second query returns empty results just by
> adding brackets. Can you please help us understand this behavior?

Supplementing the excellent info that Erick gave you:

I was slightly surprised that the first query even works like you
expect.  Here's why the second one DOESN'T work:

What you've got is a negative query clause:


At the Lucene level, a purely negative query will never work in
isolation, because you can't subtract from nothing and expect results --
you must always start with something, and THEN subtract from it.

Solr has some logic in its version of the Lucene query parser that can
detect *simple* negative query clauses and implicitly add a "*:*"
starting point before sending the query to Lucene for handling.  This
logic only works at the top level -- if the negative query is a
subordinate clause, it will not be seen by this logic, and the implicit
fix will not be added, so the query won't work.

By adding parentheses, you have turned this negative query clause into a
subordinate clause.  If you explicitly add the *:* starting point, it
will work:

(*:* -fl_monitoring_channel:36)


View raw message