I need to filter the document only if two fields of same object has the filtered value.
My data is like this:
{
"cust_data": {
"products": [
{
"item": "watch",
"qty": [
"10"
]
},
{
"item": "purse",
"qty": [
"25"
]
}
]
}
}
I am firing a query like below, my requirement is to get the customer who bought 25 quantities of watch but elasticsearch will return the above doc also only because it has 25 quantities of different item. Is there any possibility to filter the document only if both the fields of same object satisfies the query?
{
"query": {
"bool": {
"filter": [
{
"match": {
"cust_data.products.item": "watch"
}
},
{
"match": {
"cust_data.products.qty": "25"
}
}
]
}
}
}