I have a set of documents (type 'article') and I want to search for the document that have elements/objects into an array field
{
"_type": "article",
"_source": {
"title": "Article 1",
"locations": [
{
"address": "ES headquarter",
"city": "Berlin"
}
]
}
}
I want two queries (just one, but with a little variation):
- get all the articles that have locations
- get all the articles that have NO locations
I tried different things but probably I'm too bad with ElasticSearch:
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": [
{
"type": {
"value": "article"
}
},
{
"bool": {
"must_not": {
"missing": {
"field": "location",
"existence": true,
"null_value": true
}
}
}
}
]
}
}
}
this doesn't work.
- How would you fix my query?
but mainly:
- How would you perform this search for documents with a field that is an empty array?