# Getting subsequent lines after search string

**URL:** <https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466>\
**Category:** Elasticsearch\
**Created:** [January 6, 2016, 5:52am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466 "2016-01-06T05:52:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreedeep](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@sreedeep](https://discuss.elastic.co/u/sreedeep)\
**Post date:** [January 6, 2016, 5:52am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/1 "2016-01-06T05:52:19Z")

</div>

Hi,  
I have a requirement in elastic search to display n lines after the search result. So I will search with an expression and when I select the search result, it should display n lines after that. Is there a way to retrieve the continuous lines after search result?

thanks  
Sree

---

<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:** [January 6, 2016, 6:23am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/2 "2016-01-06T06:23:49Z")

</div>

What do you mean by lines?

---

<div class="post-metadata">

**Author:** ![sreedeep](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@sreedeep](https://discuss.elastic.co/u/sreedeep)\
**Post date:** [January 6, 2016, 6:51am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/3 "2016-01-06T06:51:27Z")

</div>

Hi,  
For example if I have a log.file with lines  
"Sample logs line1...  
Sample log line2.....  
Sample log line3..." and if I search for line1, I will get "Sample logs line1",  
After that I need to extract the other lines below it...

"Sample log line2.....  
Sample log line3..."

Can I use any features of ES here?  
I am using logstash to index the logs and need to extract the snippet after searching a string.

thanks  
Sree

---

<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:** [January 6, 2016, 7:03am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/4 "2016-01-06T07:03:35Z")

</div>

You could use scan/scroll, but you would then have to figure out where your line is.

---

<div class="post-metadata">

**Author:** ![sreedeep](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@sreedeep](https://discuss.elastic.co/u/sreedeep)\
**Post date:** [January 6, 2016, 7:15am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/5 "2016-01-06T07:15:36Z")

</div>

Could you please give some details?  
"but you would then have to figure out where your line is.", do you mean document position?  
I can get the document with that particular line...

---

<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:** [January 6, 2016, 7:16am UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/6 "2016-01-06T07:16:29Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-scroll.html) is scroll.

---

<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, 11:26pm UTC](https://discuss.elastic.co/t/getting-subsequent-lines-after-search-string/38466/7 "2017-07-05T23:26:50Z")

</div>


