lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: Inconsistent parsing of pure negative queries inside brackets
Date Mon, 04 Jul 2016 15:38:25 GMT
The Lucene query parser is _not_ a boolean query
language, see Hossman's excellent explanation here:
https://lucidworks.com/blog/2011/12/28/why-not-and-or-and-not/

In this case, add &debug=query to them both and you'll see something like:
---no parens
"-cat:electronics +name:test"

---parens
"+(-cat:electronics) +name:test"

The first is an optional (SHOULD) clause removing all docs with
electronics in the category
and a MUST clause for name:test

The second is a mandatory (MUST) clause removing all electronics
mentions in category
and a MUST clause for name:test.

This trips up a lot of people.

Best,
Erick


On Mon, Jul 4, 2016 at 6:04 AM, Rahul Verma <rahul.verma@contify.com> wrote:
> Hi everyone,
>
> 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?
> *1. Without Brackets:*
> { "responseHeader": { "status": 0, "QTime": 0, "params": { "q": "*:*", "
> indent": "true", "fq": "-fl_monitoring_channel: 36 AND (title: salesforce)",
> "wt": "json", "_": "1467637035433" } }, "response": { "numFound": 35541, "
> start": 0, "docs": [...
>
> *2. With Brackets:*
> { "responseHeader": { "status": 0, "QTime": 0, "params": { "q": "*:*", "
> indent": "true", "fq": "*(*-fl_monitoring_channel: 36*)* AND (title:
> salesforce)", "wt": "json", "_": "1467637344339" } }, "response": { "
> numFound": 0, "start": 0, "docs": [] } }

Mime
View raw message