在 Solr 中搜索多值字段为空或具有特定值的文档 [英] Search for document in Solr where a multivalue field is either empty or has a specific value

查看:19
本文介绍了在 Solr 中搜索多值字段为空或具有特定值的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Solr 中有一个多值字段,想查询该字段为空或包含特定值的文档.

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

推荐答案

这不是直截了当的,但它有效:

It's not straight forward, but this works:

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

我使用 Solr 5.4 来测试查询,结果令人满意:

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

{
  "myField": [ "myValue" ],
  "id": "96c353e6"
},
{
  "id": "8bcbe253"
},
{
  "myField": [ "myValue", "otherValue" ],
  "id": "c3749005"
}

这篇关于在 Solr 中搜索多值字段为空或具有特定值的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆