Search for document in Solr where a multivalue fie

2020-04-05 09:11发布

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

1条回答
可以哭但决不认输i
2楼-- · 2020-04-05 09:19

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"
}
查看更多
登录 后发表回答