lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <>
Subject Re: OR query with null value and non-null value(s)
Date Thu, 06 Jun 2013 18:37:33 GMT
On 6/6/2013 12:28 PM, Rahul R wrote:
> I have recently enabled facet.missing=true in solrconfig.xml which gives
> null facet values also. As I understand it, the syntax to do a faceted
> search on a null value is something like this:
> &fq=-price:[* TO *]
> So when I want to search on a particular value (for example : 4)  OR null
> value, I would expect the syntax to be something like this:
> &fq=(price:4+OR+(-price:[* TO *]))
> But this does not work. After searching around for more, read somewhere
> that the right way to achieve this would be:
> fq=-(-price:4+AND+price:[*+TO+*])
> Now this does work but seems like a very roundabout way. Is there a better
> way to achieve this ?

Pure negative queries don't work -- you have to have results in the 
query before you can subtract.  For some top-level queries, Solr is able 
to detect this situation and fix it internally, but on inner queries you 
must explicitly state your intentions.  It is best if you always use 
'*:* -query' syntax, just to be safe.

fq=(price:4+OR+(*:* -price:[* TO *]))


View raw message