Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch filter query for having null value

I want to filter data from elasic search document like documents which is having blank list. HOw can i achieve that. Suppose i want this results.

1) { name:'vipul', gender:[] }

this is having blank list

like image 693
vipul prajapati Avatar asked Oct 17 '25 18:10

vipul prajapati


1 Answers

You can combine a bool query with a exists query like so:

"bool": {
    "must_not": [
        {
            "exists": {
                "field": "gender"
            }
        }
    ]
}
like image 185
hudsonb Avatar answered Oct 20 '25 06:10

hudsonb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!