# Extract stored field in elasticsearch document using start and end offset

**URL:** <https://discuss.elastic.co/t/extract-stored-field-in-elasticsearch-document-using-start-and-end-offset/327598>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [March 13, 2023, 9:43pm UTC](https://discuss.elastic.co/t/extract-stored-field-in-elasticsearch-document-using-start-and-end-offset/327598 "2023-03-13T21:43:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ancel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ancel/32/116749_2.png) [@Ancel](https://discuss.elastic.co/u/Ancel)\
**Post date:** [March 13, 2023, 9:43pm UTC](https://discuss.elastic.co/t/extract-stored-field-in-elasticsearch-document-using-start-and-end-offset/327598/1 "2023-03-13T21:43:30Z")

</div>

Hi all, I am seeking some pointers. Given the start and end offsets of text within a document field (e.g. as provided by the termvectors API), I would like to extract the stored text between those offsets. This text was obtained using the ingest attachment plugin, so the text is now present in the index.

My idea is to first fetch the document in Elasticsearch and store that in a variable in a programming language. Then I can get the text from the field, and find the text of interest based on the start and end offsets - doing all of that outside Elasticsearch. Is there a way to do this effectively within Elasticsearch?

---

<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:** [April 10, 2023, 9:43pm UTC](https://discuss.elastic.co/t/extract-stored-field-in-elasticsearch-document-using-start-and-end-offset/327598/2 "2023-04-10T21:43:45Z")

</div>

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