lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Van Tassell, Kristian" <>
Subject RE: How to query Solr for empty field or specific value
Date Tue, 02 Jul 2013 20:26:14 GMT
Thank you!

-----Original Message-----
From: Jack Krupansky [] 
Sent: Tuesday, July 02, 2013 3:05 PM
Subject: Re: How to query Solr for empty field or specific value

Better to define color.not_null as a boolean field and always initialize as either true or

But, even without that you need write a pure negative query or clause as

    (*:* -term)


    select?q=*:*&fq=((*:* -color:[* TO *]) OR color:blue)


    select?q=*:*&fq=((*:* -color.not_null:[* TO *]) OR color:blue)

-- Jack Krupansky

-----Original Message-----
From: Van Tassell, Kristian
Sent: Tuesday, July 02, 2013 3:47 PM
Subject: How to query Solr for empty field or specific value


I'm using Solr 4.2 and am trying to get a specific value (blue) or null field (no color) returned
by my filter query. My results should yield 3 documents (If I execute the two separate filters
in different queries, I get
2 hits for one query and 1 for the other).

I've tried this (blue or no color set):

select?q=*:*&fq=(-color:[* TO *] OR color:blue)

When that returned zero hits, I added a new field called "color.not_null" 
and am setting it only if a color is defined (thinking there was a problem with using the
same field name).

select?q=*:*&fq=(-color.not_null:[* TO *] OR color:blue)

That too yielded zero results. Again, executing them separately does return hits (3).

Does anyone see what I might be doing wrong? Thanks in advance, Kristian 

View raw message