# Get list of documents from a specific segment

**URL:** <https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663>\
**Category:** Elasticsearch\
**Created:** [June 9, 2023, 10:21pm UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663 "2023-06-09T22:21:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvarano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cvarano/32/122082_2.png) [@cvarano](https://discuss.elastic.co/u/cvarano)\
**Post date:** [June 9, 2023, 10:21pm UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663/1 "2023-06-09T22:21:57Z")

</div>

Is there a way to inspect which documents are stored in a specific segment? I can get the segments from the cat segments api, but it only tells me the total # of docs.

I want to perform two functions:

1. Given a segment id, return the list of documents in that segment
2. Given a document id, return the segment id of the segment it is in (if it is in multiple segments due to deletions, return all segments)

Does such functionality exist?

Thank you!  
Chris

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 10, 2023, 4:55am UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663/2 "2023-06-10T04:55:31Z")

</div>

As far as i know it does not exist. Why would you need this?

---

<div class="post-metadata">

**Author:** ![cvarano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cvarano/32/122082_2.png) [@cvarano](https://discuss.elastic.co/u/cvarano)\
**Post date:** [June 12, 2023, 4:25pm UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663/3 "2023-06-12T16:25:23Z")

</div>

For inspection and understanding; not a production use case

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 13, 2023, 1:45am UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663/5 "2023-06-13T01:45:36Z")

</div>

As Christian mentioned, you cannot do this.

---

<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 11, 2023, 1:46am UTC](https://discuss.elastic.co/t/get-list-of-documents-from-a-specific-segment/335663/6 "2023-07-11T01:46:09Z")

</div>

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