Reputation: 562
I have a query that should be getting any row that matches one of these ids. The query returns nothing, but should return two rows. If I remove one id I get one row back. I'm assuming it's doing an AND rather than an OR. How can I change this? (In practice I have many more ids to query)
{
"query": {
"bool": {
"filter": [
{
"term": {
"_id": 1273359
}
},
{
"term": {
"_id": 480421
}
}
]
}
}
}
Upvotes: 2
Views: 3577
Reputation: 410
Why complicate your query ! Use this sugar syntaxe instead :
{
"query": {
"ids" : {
"values" : ["0", "1"]
}
}
}
Upvotes: 0
Reputation: 217494
Try the ids
filter instead
{
"query": {
"bool": {
"filter": [
{
"ids": {
"values": ["1273359", "480421"]
}
}
]
}
}
}
Note that the query you had meant "find documents whose id is 1273359 AND 1273359", which is not possible in practice. With the above query, you have an OR instead of a AND and it will work.
Upvotes: 6