# Nested queries not returning all inner hits

**URL:** <https://discuss.elastic.co/t/nested-queries-not-returning-all-inner-hits/57369>\
**Category:** Elasticsearch\
**Created:** [August 5, 2016, 4:18pm UTC](https://discuss.elastic.co/t/nested-queries-not-returning-all-inner-hits/57369 "2016-08-05T16:18:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanBlum](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@DanBlum](https://discuss.elastic.co/u/DanBlum)\
**Post date:** [August 5, 2016, 4:18pm UTC](https://discuss.elastic.co/t/nested-queries-not-returning-all-inner-hits/57369/1 "2016-08-05T16:18:35Z")

</div>

I have documents each of which have many nested objects containing analyzed text (think paragraphs of a document). I am running nested span near queries in order to find the documents containing phrases and defining inner hits on the query so I can identify which nested objects matched for each document.

I get inner hits, and in general when there are multiple matching nested objects I get multiple inner hits for a document - but often I am missing some. E.g. there may be 5 nested objects in a document which should match (by inspecting the text), but I only get 3 inner hits for the document.

Is this behavior known? Is it intentional for some reason? The only plausible reason I can think of for it being intentional is that the excluded hits are lower-scoring, although they should not be in the cases I have checked (and I definitely see cases where I get back inner hits for a document with different scores).

---

<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:** [July 5, 2017, 10:29pm UTC](https://discuss.elastic.co/t/nested-queries-not-returning-all-inner-hits/57369/2 "2017-07-05T22:29:45Z")

</div>


