I need to return results that do not include docs with certain ids. Elasticsearch allows us to specify which ids are allowed but I see no way to disallow certain ids. In my case I want to not return things the user has already seen so the list will be different for each user.
You can achieve this by adding a bool/must_not
filter containing an ids
filter with an array of ids you don't want to appear, like this:
{
"query": {
"bool": {
"must": [
... <--- your other filters go here
],
"must_not": [
{
"ids": {
"values": [
"id1", "id2" <--- add all the ids you DON'T want in here
]
}
}
]
}
}
}
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