Negating the exists query as suggested by docs does not seem to work as I would intend it, at least with Elasticsearch 7.14.
When I send GET to /master_user/_search
with payload
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "the_field"
}
}
}
}
}
all hits are returned, including the ones where the_field
has an actual value.
If instead I am sending GET to /master_user/_search?q=NOT _exists_:the_field
with no payload, the expected hits are returned.
My issue in particular is that I am generating the JSON payload reported above via Java client as
QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("the_field"))
and have no clue about how to generate the working call.
Any hint?