ES查询-空字段和非空字段结果

mysql查询返回某个字段为空值的结果写法是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": "字段名"
        }
      }
    }
  }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章