elasticsearch 空字段请求

yhxst69z  于 2023-01-29  发布在  ElasticSearch
关注(0)|答案(2)|浏览(130)

我有一个GET请求,我需要过滤包含空字段的文档,在ES中有什么方法可以做到这一点吗?因为我知道不能搜索空字段,过滤器的工作原理与搜索相同吗?在ElasticSearch中,此文档字段实际上是一个2D数组。
curl -X GET -H“内容类型:应用程序/json”“本地主机.blahblah/”-d '{“查询”:{“布尔值”:{“筛选器”:{“术语”:{“文档”:[“”] }}}}'
curl -X GET -H“内容类型:应用程序/json”“我的索引/”-d '{“查询”:{“布尔值”:{“筛选器”:{“术语”:{“文档”:[“”] }}}}'

h5qlskok

h5qlskok1#

请尝试下面的代码:

{
  "query": {
    "bool": {
      "must_not": [
        {
          "wildcard": {
            "documents": {
              "value": "*"
            }
          }
        }
      ]
    }
  }
}
inb24sb2

inb24sb22#

将exists查询与must_not布尔查询一起使用,可以查找缺少字段索引值(可以为空或null)的文档。
质询:

{
  "query": {
  "bool" : {
    "must_not": [
      {
        "exists": {
          "field": "documents"
        }
      }
    ]
  }

相关问题