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: Simplification of boolean query failed
Date Mon, 05 Dec 2011 13:30:13 GMT
Right, the Solr/Lucene query syntax isn't true Boolean logic, so
applying all the neat DeMorgan's rules is sometimes surprising.

The first form take all records with event dates or that fall outside your range
and inverts the results.

The second selects all documents that fall in the indicated date range
and removes all documents from that set that have dates.

If your second clause were something like (*:* -event_date:[* TO *]) I think
you'd get what you expect.

Best
Erick

On Fri, Dec 2, 2011 at 12:47 PM, Mark D Sievers <mark.sievers@gmail.com> wrote:
> I've put the question nicely formatted on StackOverflow here
> http://stackoverflow.com/questions/8360257/solr-lucene-why-is-this-or-query-failing-when-the-two-individual-queries-suc
>
> Here is that question Verbatim:
>
> I have a Solr document schema with with a solr.TrieDateField and noticed
> this boolean query (not authored by me) which I thought could benefit from
> some simplification;
>
> q=-(-event_date:[2011-12-02T00:00:00.000Z TO NOW/DAY+90DAYS] OR
> (event_date:[* TO *]))
>
> which means *events within the next 90 days or non-events* (See Pure
> Negative<http://wiki.apache.org/solr/SolrQuerySyntax#Differences_From_Lucene_Query_Parser>for
> Solr boolean
> NOT notation) . My simplification looked like
>
> q=event_date:[2011-12-02T00:00:00.000Z TO NOW/DAY+90DAYS] OR
> -event_date:[* TO *]
>
> As stated, this didn't work (0 results). So as a test I ran the two sides
> of the OR query individually and the sum of the two results (both non-zero)
> equaled the sum of the original query and I can't come up with a good
> explanation why. Running with debugQuery=true didn't present anything
> helpful.
> Thanks,
>
> Mark

Mime
View raw message