If I want to return all the documents which have an empty property (IMG) I can do something like that:
GET something/_search/?
{
"query": {
"term": {"IMG": ""}
}
}
It works because IMG is a keyword. If I want the exact inverse, which means get all the documents where IMG is not null, what should I type? Is there an "inverse" of term query?
In other words, is there a way with Elasticsearch to get documents where a property is not empty?
Your solution above would also return documents where the field is null, which you don't want I guess. So the correct solution would be this one:
GET memoire/_search/?
{
"query": {
"bool": {
"filter": {
"exists": {
"field": "test"
}
},
"must_not": {
"term": {
"test.keyword": ""
}
}
}
}
}
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