elasticsearch查询某个字段为空值的结果

传统sql查询返回某个字段为空值的结果写法是select * from 表名 where 字段名 is null

在elasticsearch中查询语句为

GET index/type/_search 

{
  "query": {
    "bool": {
      "must_not": {
        "exists": {
          "field": "字段名"
        }
      }
    }
  }
}

反之,查询字段不为空值的语句为

GET index/type/_search

{
  "query": {
    "bool": {
      "must": {
        "exists": {
          "field": "字段名"
        }
      }
    }
  }
}

发布了276 篇原创文章 · 获赞 109 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/lvtula/article/details/104625976