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

左心房为你撑大大i 提交于 2019-12-04 03:22:45

问题


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:


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"
}


来源:https://stackoverflow.com/questions/35633037/search-for-document-in-solr-where-a-multivalue-field-is-either-empty-or-has-a-sp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!