# Retrieve multiple nested documents around the query matched document

**URL:** <https://discuss.elastic.co/t/retrieve-multiple-nested-documents-around-the-query-matched-document/250139>\
**Category:** Elasticsearch\
**Created:** [September 28, 2020, 7:37am UTC](https://discuss.elastic.co/t/retrieve-multiple-nested-documents-around-the-query-matched-document/250139 "2020-09-28T07:37:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![verdict-lg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/verdict-lg/32/76310_2.png) [@verdict-lg](https://discuss.elastic.co/u/verdict-lg)\
**Post date:** [September 28, 2020, 7:37am UTC](https://discuss.elastic.co/t/retrieve-multiple-nested-documents-around-the-query-matched-document/250139/1 "2020-09-28T07:37:00Z")

</div>

Is there a way to retrieve multiple documents around the matching nested document. For example in this document:

```auto
Book ID: ISBN8137183
Book Name: Name of the Wind
Chapters: {
{Chapter ID: 1
Gist: some_text_1
},
{Chapter ID: 2
Gist: some_text_2
},
{Chapter ID: 3
Gist: some_text_3
},
{Chapter ID: 4
Gist: some_text_4
},
{Chapter ID: 5
Gist: some_text_5
},
}

```

In this document where the **Chapters** field is nested, say my query matches the nested document with Chapter ID 3 then I want to also retrieve {n-1, n+1} documents i.e. I want to retrieve {2,3,4} chapter nested documents. Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![verdict-lg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/verdict-lg/32/76310_2.png) [@verdict-lg](https://discuss.elastic.co/u/verdict-lg)\
**Post date:** [October 14, 2020, 9:35am UTC](https://discuss.elastic.co/t/retrieve-multiple-nested-documents-around-the-query-matched-document/250139/2 "2020-10-14T09:35:10Z")

</div>

Hi,

Any help here would be great !

---

<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:** [November 11, 2020, 9:35am UTC](https://discuss.elastic.co/t/retrieve-multiple-nested-documents-around-the-query-matched-document/250139/3 "2020-11-11T09:35:12Z")

</div>

Closed on November 11, 2020, 9:35am UTC

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