Solr filter request including NOT and OR

To request a filter in Solr, I need to include all documents of an unspecified type, as well as any documents of this type that are relevant in a specific field.

I tried this:

fq=(-type_id:(A) OR content:(['' TO *])) 

But this excludes type_id B, C, etc. documents that are null content . ( type_id is the string field, and content is text .)

I saw this question: Complex SOLR query, including NOT and OR , and this post about operators: http://robotlibrarian.billdueber.com/solr-and-boolean-operators/ . I think the syntax that I have should be correct. Can anyone see my mistake?


Update: I am using LuceneQParser. It parses the filter request above as

 -type_id:A content:['' TO *] 

It parses the filter request suggested in the comments ( -type_id:A OR (content:[* TO *] AND type_id:A) ), as

 -type_id:A (+content:[* TO *] +type_id:A) 

therefore no results.

+6
source share
1 answer

Denial requires a full set to match it, so your filter should be:

 fq=((*:* AND -type_id:A) OR content:(['' TO *])) 
+11
source

Source: https://habr.com/ru/post/945806/


All Articles