# Question About Inner\_Hits with Multiple Nested Objects

**URL:** <https://discuss.elastic.co/t/question-about-inner-hits-with-multiple-nested-objects/85992>\
**Category:** Elasticsearch\
**Created:** [May 16, 2017, 5:16pm UTC](https://discuss.elastic.co/t/question-about-inner-hits-with-multiple-nested-objects/85992 "2017-05-16T17:16:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [May 16, 2017, 5:16pm UTC](https://discuss.elastic.co/t/question-about-inner-hits-with-multiple-nested-objects/85992/1 "2017-05-16T17:16:53Z")

</div>

I have the query below which test fields defined in two separate nested paths and the query works as expected. However, I would like to return only the inner\_hits that meet both criteria. Is that doable in ES? If so, how would I go about adding it? I tried tacking it onto the outer query but that does not work. Any help would be appreciated. Thanks.

Kevin

{  
"size": 10,  
"query" : {  
"bool" : {  
"must": [  
{"nested": {"path": "segments",  
"query": {  
"bool": {  
"must": [  
{"exists": {"field": "segments.entities.disambiguationResults"}},  
{"regexp": {"segments.entities.type": "PERSON"}}  
]  
}}}  
}  
],  
"must\_not": [  
{"nested": {"path": "segments.entities.attributes",  
"query": {  
"bool": {  
"must": [  
{"exists": {"field": "segments.entities.attributes.firstName"}}  
]  
}  
}  
}  
}  
]  
}  
}  
}

---

<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 13, 2017, 5:17pm UTC](https://discuss.elastic.co/t/question-about-inner-hits-with-multiple-nested-objects/85992/2 "2017-06-13T17:17:12Z")

</div>

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