Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search for document in Solr where a multivalue field is either empty or has a specific value

I have a multivalue field in Solr, and want to query for documents where this field is either empty, or contains a specific value.

like image 789
neu242 Avatar asked Feb 25 '16 16:02

neu242


1 Answers

It's not straight forward, but this works:

myField:"myValue" OR (*:* NOT myField:["" TO *])

I used Solr 5.4 to test the query, which had satisfying results:

{
  "myField": [ "myValue" ],
  "id": "96c353e6"
},
{
  "id": "8bcbe253"
},
{
  "myField": [ "myValue", "otherValue" ],
  "id": "c3749005"
}
like image 178
neu242 Avatar answered Sep 25 '22 14:09

neu242