Reputation: 601
I’d like to combine ids
query with must_not
clause. I’m using (re)tire gem with rails application.
I’m doing something like this:
query do
ids ["foo", "bar", "test"]
end
Which works. However, when I’m trying to combine it with must_not
clause, I’m getting error – must_not
works only withing boolean
scope, which does not include ids
query. Is there any way to combine that two queries?
Upvotes: 3
Views: 2224
Reputation: 52368
The ES query that you need to use is this one:
GET /some_index/some_type/_search
{
"query": {
"bool": {
"must": [
{
"ids": {
"values": ["foo", "bar", "test"]
}
}
],
"must_not": [
{
"match": {
"name": "whatever"
}
}
]
}
}
}
So, you need boolean scope, a must
with your ids
and a must_not
with your must not match queries.
Upvotes: 9