For a filter query in Solr, I need to include all documents not of a certain type, plus any documents of that type which have a value in a certain field.
I tried this:
fq=(-type_id:(A) OR content:(['' TO *]))
But it is excluding documents of type_id
B, C, etc. which have null content
. (type_id
is a string
field and content
is text
.)
I have seen this question: Complex SOLR query including NOT and OR and this post about operators: http://robotlibrarian.billdueber.com/2011/12/solr-and-boolean-operators/. I think the syntax I have should be correct. Can anyone see my error?
Update: I am using the LuceneQParser. It parses the filter query above as
-type_id:A content:['' TO *]
It parses the filter query suggested in the comments (-type_id:A OR (content:[* TO *] AND type_id:A)
) as
-type_id:A (+content:[* TO *] +type_id:A)
so no results.
The negation needs a complete set to match against it, so your filter should be:
fq=((*:* AND -type_id:A) OR content:(['' TO *]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With