# Is it possible to combine two different fields of same object to filter the document?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-combine-two-different-fields-of-same-object-to-filter-the-document/234483>\
**Category:** Elasticsearch\
**Created:** [May 27, 2020, 8:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-different-fields-of-same-object-to-filter-the-document/234483 "2020-05-27T08:09:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MirunaliniSridharan](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@MirunaliniSridharan](https://discuss.elastic.co/u/MirunaliniSridharan)\
**Post date:** [May 27, 2020, 8:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-different-fields-of-same-object-to-filter-the-document/234483/1 "2020-05-27T08:09:27Z")

</div>

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"  
}  
}  
]  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 24, 2020, 8:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-combine-two-different-fields-of-same-object-to-filter-the-document/234483/2 "2020-06-24T08:09:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
