: 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