How to do an OR expression that filters to either blank field or a specific value?
This does not seem to do it:
q=(-PrivacyLevel:*) OR PrivacyLevel:2
Thanks
Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter. The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).
Solr supports a variety of Response Writers to ensure that query responses can be parsed by the appropriate language or application. The wt parameter selects the Response Writer to be used. The table below lists the most common settings for the wt parameter.
The fq (Filter Query) Parameter The fq parameter defines a query that can be used to restrict the superset of documents that can be returned, without influencing score. It can be very useful for speeding up complex queries, since the queries specified with fq are cached independently of the main query.
The answer is to use double negation as suggested by Maurizio In denmark. Mathematically this is identical to the non-negated query, however, Solr only understands the double negated version:
q=-(-PrivacyLevel:2 PrivacyLevel:*)
Note: This also works for filter queries:
fq=-(-PrivacyLevel:2 PrivacyLevel:*)
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