I would like to create a query in elastic where I get all documents that match a value and don't have a specific field: what I'm trying to do is the following:
{
"query": {
"bool": {
"must": [
{
"match": {
"some-field.b": true
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "some-other-field.a"
}
}
}
}
]
}
}
}
Even if I change a document in elastic and give a value to the some-other-field.a the query keeps returning me the same number of total hits. Any idea why is this happening?
The only way I found to change this is by adding the a minimum score to the query but I'm not sure I really understand the concept of the score. I would like to get the documents only if both conditions are met.
I noticed one other thing. If I repeat the query while having a minimum score the number of the returned hits varies.