# Print nearby lines after query result

**URL:** <https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810>\
**Category:** Elasticsearch\
**Created:** [May 29, 2014, 3:18pm UTC](https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810 "2014-05-29T15:18:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Senthil\_Raja](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Senthil\_Raja](https://discuss.elastic.co/u/Senthil_Raja)\
**Post date:** [May 29, 2014, 3:18pm UTC](https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810/1 "2014-05-29T15:18:47Z")

</div>

Team,

As per our requirement, i have to search a string in ES logs. And, print  
five lines before and after the result query.

Is there any way to do that ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8881e7d5-c659-49c0-8481-595bdab0a7cb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8881e7d5-c659-49c0-8481-595bdab0a7cb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Senthil\_Raja](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@Senthil\_Raja](https://discuss.elastic.co/u/Senthil_Raja)\
**Post date:** [May 29, 2014, 3:29pm UTC](https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810/2 "2014-05-29T15:29:17Z")

</div>

In unix we are using grep -A 5 -B 5 "" . Looking for the similar  
requirement.

On Thursday, May 29, 2014 8:48:47 PM UTC+5:30, Senthil Raja wrote:

> Team,
> 
> As per our requirement, i have to search a string in ES logs. And, print  
> five lines before and after the result query.
> 
> Is there any way to do that ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/39bf46eb-e749-44e4-8a9e-3658b32e5ce7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/39bf46eb-e749-44e4-8a9e-3658b32e5ce7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [May 30, 2014, 4:53am UTC](https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810/3 "2014-05-30T04:53:07Z")

</div>

I'd be curious to hear if anyone has any clever suggestions for this, too.

## Otis

Performance Monitoring \* Log Analytics \* Search Analytics  
Solr & Elasticsearch Support \* [http://sematext.com/](http://sematext.com/)

On Thursday, May 29, 2014 11:29:18 AM UTC-4, Senthil Raja wrote:

> In unix we are using grep -A 5 -B 5 "" . Looking for the similar  
> requirement.
> 
> On Thursday, May 29, 2014 8:48:47 PM UTC+5:30, Senthil Raja wrote:
> 
> > Team,
> > 
> > As per our requirement, i have to search a string in ES logs. And, print  
> > five lines before and after the result query.
> > 
> > Is there any way to do that ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/448f18d3-131c-44d4-9efd-daa57ef72069%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/448f18d3-131c-44d4-9efd-daa57ef72069%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:25am UTC](https://discuss.elastic.co/t/print-nearby-lines-after-query-result/17810/4 "2017-07-06T01:25:59Z")

</div>


