Elastic Search查询以检查2个字段中的空值

Sel*_*lva 0 notnull elasticsearch

什么是弹性搜索查询,用于搜索“ field1为null field2为null”的文档。

我正在使用elasticSearch 5.3 ...

小智 5

这个查询对我有用:

curl -XGET "http://localhost:9200/my_null_val/_search?pretty" -d '
{
  "query": {
    "bool":{
      "must_not":{
        "bool": {
          "must": [
            {"exists" : { "field" : "field1" }},
            {"exists" : { "field" : "field2" }}
          ]
        }
      }
    }
  }
}'
Run Code Online (Sandbox Code Playgroud)

作为提示,您可以认为与field1 is null **OR** field2 is null等同NOT (field1 is not null **AND** field2 is not null)

它也被称为德摩根定律