4

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

vipul prajapati
  • 263
  • 2
  • 8
  • 1
    This answer may help: https://stackoverflow.com/questions/32949321/best-way-to-check-if-a-field-exist-in-an-elasticsearch-document/32949472#32949472 (hint: use `bool/must_not/exists`) – Val Oct 22 '18 at 14:21

1 Answers1

12

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

"bool": {
    "must_not": [
        {
            "exists": {
                "field": "gender"
            }
        }
    ]
}
Most Wanted
  • 6,254
  • 5
  • 53
  • 70
hudsonb
  • 2,214
  • 19
  • 20