Elastic Search query for empty date field

Viewed 33

Currently I have written the below query for finding null values in historical data for approximately last 4 months in the elastic search:

GET _search
{
  "size":2,
  "query":{
    "bool":{
    "must":[  {
      "match": {"product": "device"}
    },
    {
    "range": {
                "time": {
            "from": "2022-06-01T05:00:00.000Z",
            "to": "2022-09-15T23:59:59.999Z"
                        }
            }
    }
    ],
    "filter":[{"bool": {
                        "must": [{"exists": {"field": "device_id"}},{"term": {"device_id":""}}]
                    }}]
    }
  }
}

But it only works for string fields as device_id is a string here. The query fails for date and bool fields.

I want to write a similar query for date and bool fields.

Can someone help me out on telling how it can be done?

0 Answers
Related