I want to fetch documents with ids in specific type. For example right now I have wrote this query in Sense. This query is returning me all the documents with these ids in type product.
POST /_search
{
"query": {
"ids" :{
"type" : "product",
"values" : ["100005","10002010093"]
}
}
}
But what I want here is something like this
POST /_search
{
"query": [
{
"ids" :{
"type" : "product",
"values" : ["100005","10002010093"]
}
},
{
"ids" :{
"type" : "store",
"values" : ["100003","1000201"]
}
}
]
}
or
POST /_search
{
"query":{
"ids" :[
{
"type" : "product",
"values" : ["100005","10002010093"]
},
{
"type" : "store",
"values" : ["100003","1000201"]
}
]
}
}
Is there any way to get it done?
You simply need to use the bool/filter
query:
POST /_search
{
"query": {
"bool": {
"should": [
{
"ids": {
"type": "product",
"values": [
"100005",
"10002010093"
]
}
},
{
"ids": {
"type": "store",
"values": [
"100003",
"1000201"
]
}
}
]
}
}
}
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