# Complicated Nested Query

**URL:** <https://discuss.elastic.co/t/complicated-nested-query/239925>\
**Category:** Elasticsearch\
**Created:** [July 5, 2020, 1:33pm UTC](https://discuss.elastic.co/t/complicated-nested-query/239925 "2020-07-05T13:33:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacksonpv](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@jacksonpv](https://discuss.elastic.co/u/jacksonpv)\
**Post date:** [July 5, 2020, 1:33pm UTC](https://discuss.elastic.co/t/complicated-nested-query/239925/1 "2020-07-05T13:33:10Z")

</div>

Hi Guys Please suggest a query or approach for this problem below Here I have two records in my type called "journey"

Record 1

{  
"journeyid":1,  
"journeyname":"test1",  
"journeydetail:[  
{  
"pickupcode":"Banglore",  
"deliverycode":" Maharastra"  
},  
{  
"pickupcode":"Delhi"  
"deliverycode":" Lucknow"  
}]  
}

Record2

{  
"journeyid":2,  
"journeyname":"test2",  
"journeydetail:[  
{  
"pickupcode":"Banglore",  
"deliverycode":"Kerala"  
}  
]  
}  
Input  
I have added pickupcode:banglore in my excluded list

Expected result  
Record 1 only show because it contains two nested object where banglore has only restriction and other cities delhi and lucknow has accessible. So that record must show

Record 2 should not show beacuse it has only one object there banglore is restricted

---

<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:** [August 2, 2020, 1:33pm UTC](https://discuss.elastic.co/t/complicated-nested-query/239925/2 "2020-08-02T13:33:19Z")

</div>

Closed on August 2, 2020, 1:33pm UTC

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