I recently updated to the newer version of Elasticsearch and realized that the missing query is missing. I understand that you could use must_not with exists. But for my particular scenario it isn't working. I have the following configuration:
filtered = {
function_score: {
functions: [functions],
query: {
bool: {
must: [must have features],
must_not: [must not have features],
filter: filter,
},
},
}
};
and the filter array looks like the following:
[
...
{
bool: {
should: [
{ missing: { field: "test" } },
{
script: {
script: "doc['id'].value == doc['test'].value"
}
},
]
}
}
...
]
Basically saying either field test
should be missing or it should be equal to the id of the same document.
This was working fine but now I don't know how to replace this with exists
query. I have tried the following:
[
...
{
bool: {
should: [
{
bool: {
must_not: [
{ exists: {field: "test"} }
]
}
},
{
script: {
script: "doc['id'].value == doc['test'].value"
}
},
]
}
}
...
]
This however completely ignores the script query and returns documents only if the test
field is missing.