Thursday, August 25, 2016

Search documents having a specific field with a null value in Elasticsearch

To search documents having a specific field with a null value in Elasticsearch, do as follows:

curl http://localhost:9200/answer/_search?pretty -d '
{
  "query": {
    "constant_score": {
      "filter": {
        "missing": {
          "field" : "body"
        }
      }
    }
  }
}'

Reference:
https://www.elastic.co/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html

No comments:

Post a Comment