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": "字段名"
        }
      }
    }
  }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章