# Including only nested documents that caused the 'hit' of the parent doc

**URL:** <https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808>\
**Category:** Elasticsearch\
**Created:** [May 24, 2016, 8:46am UTC](https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808 "2016-05-24T08:46:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![guybowden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guybowden/32/9907_2.png) [@guybowden](https://discuss.elastic.co/u/guybowden)\
**Post date:** [May 24, 2016, 8:46am UTC](https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808/1 "2016-05-24T08:46:07Z")

</div>

I have an index that looks something like this:

```
{
  field:'value',
  // ... more fields ...
  prices: [{"date":"2016-01-01", "nights":1, "price":300},...]
}

```

The `prices` array can contain around 10,000 entries per document.

I have a search query that will fetch all documents were the `date` and `nights` and `price` values all meet some requirements like "where date is X, nights is Y and price is between A and B"

When I fetch the results, I have to exclude the `prices` array from the source fields as it's way too big to be performant when retrieving 50 documents.

What I would like to do is retrieve the price entries that caused the doc to match in the first place.

---

<div class="post-metadata">

**Author:** ![chris67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris67/32/9870_2.png) [@chris67](https://discuss.elastic.co/u/chris67)\
**Post date:** [May 24, 2016, 9:06am UTC](https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808/2 "2016-05-24T09:06:10Z")

</div>

Have you tried using inner\_hits? [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html)

---

<div class="post-metadata">

**Author:** ![guybowden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guybowden/32/9907_2.png) [@guybowden](https://discuss.elastic.co/u/guybowden)\
**Post date:** [May 24, 2016, 9:09am UTC](https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808/3 "2016-05-24T09:09:49Z")

</div>

I am on that page right now 🙂 thanks.

---

<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:49pm UTC](https://discuss.elastic.co/t/including-only-nested-documents-that-caused-the-hit-of-the-parent-doc/50808/4 "2017-07-05T22:49:37Z")

</div>


