How to query Null values?

Hi

I actually loaded data from sql to elasticsearch using logstash jdbc plugin. What I'm facing issue was some of the fields was null and in elasticsearch it is saving as

      "emp_ssnlast4": null

So i'm not able to query

Any help was appreciated

Thanks

Could you try this query :

GET index/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "emp_ssnlast4"
          }
        }
      ]
    }
  }
}

But this will also returns documents where the field emp_ssnlast4 is missing.

What you could also do, is to set a default (placeholder) value in the mapping for null values, then query on this placeholder.

https://www.elastic.co/guide/en/elasticsearch/reference/current/null-value.html

so thanks for the reply and the emp_ssnlast4 is integer type how we need to query

If you want to use the null_value parameter for an integer (the value must be the same datatype), so you could set 0 or -1, depending on your logic?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.