How do I go about fetching all documents w/o any objects in a field?
I have the following mapping:
"properties" : {
"name": {
"type": "text"
},
"nestedArray": {
"type": "nested",
"properties": {
"prop1": {
"type": "text"
},
"prop2": {
"type": "text"
}
}
}
}
and I want to get all documents where "nestedArray" is empty or doesn't exist.
I'm using elasticSearch 5.0
I think exists query would solve this problem. Try following query
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "nestedArray",
"query": {
"bool": {
"filter": {
"exists": {
"field": "nestedArray"
}
}
}
}
}
}
]
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With