lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Help me understand query syntax of subqueries
Date Tue, 01 Jun 2010 23:13:38 GMT

: Any idea why this query returns 0 records:
:     "sexual assault" AND (-obama)
: while this one returns 1400 ?
:     "sexual assault" AND -(obama)

in the first one, the parans create a boolean query consisting of a single 
negated clause -- but pure negative boolean queries (ie: boolean queries 
were every clause is negated) by definition can't match anything -- and 
then you say in your outermost query that that boolean query (that matches 
nothing) must match (because it's part of an "AND")  this is expalined in 
your debugging info...

: "sexual assault" AND (-obama), translates to:  +text:"sexual assault"
: +(-text:obama), returns 0 records

In the second query, the negation applies to the entire boolean query 
-- since it contains one positive clause it's optimized away, also visible 
in your debugging info...

: "sexual assault" AND -(obama), translates to:  +text:"sexual assault"
: -text:obama, returns 1400 records


: (-obama), translates to: -text:obama, returns 716295 records
: -(obama), translates to: -text:obama, returns 716295 records

...this is because at the "top level" Solr does allow "pure negative" 
queries by inverting the search for you -- but it can't do that for sub 
queries.


-Hoss


Mime
View raw message