# How to extract a portion of text based on keywords

**URL:** <https://discuss.elastic.co/t/how-to-extract-a-portion-of-text-based-on-keywords/48376>\
**Category:** Elasticsearch\
**Created:** [April 26, 2016, 4:13am UTC](https://discuss.elastic.co/t/how-to-extract-a-portion-of-text-based-on-keywords/48376 "2016-04-26T04:13:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![b4me](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@b4me](https://discuss.elastic.co/u/b4me)\
**Post date:** [April 26, 2016, 4:13am UTC](https://discuss.elastic.co/t/how-to-extract-a-portion-of-text-based-on-keywords/48376/1 "2016-04-26T04:13:53Z")

</div>

Hi,

I have a huge size of document per record and I need to extract a portion of document content based on keyword per record. I am wondering if there is a feature available in Elasticsearch to allow me to define portion (e.g. x number of words after the key words or n bytes proceeding the keyword or something similar) to be returned?

Thanks.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [May 2, 2016, 12:59pm UTC](https://discuss.elastic.co/t/how-to-extract-a-portion-of-text-based-on-keywords/48376/2 "2016-05-02T12:59:43Z")

</div>

Hi,

I am not sure whether this really fits your use case but it sounds to me that maybe [highlighters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html) can help.

Daniel

---

<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:54pm UTC](https://discuss.elastic.co/t/how-to-extract-a-portion-of-text-based-on-keywords/48376/3 "2017-07-05T22:54:42Z")

</div>

Closed on July 5, 2017, 10:54pm UTC


