# Finding out offsets of query matches in indexed text

**URL:** <https://discuss.elastic.co/t/finding-out-offsets-of-query-matches-in-indexed-text/4645>\
**Category:** Elasticsearch\
**Created:** [June 17, 2011, 8:30am UTC](https://discuss.elastic.co/t/finding-out-offsets-of-query-matches-in-indexed-text/4645 "2011-06-17T08:30:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)\
**Post date:** [June 17, 2011, 8:30am UTC](https://discuss.elastic.co/t/finding-out-offsets-of-query-matches-in-indexed-text/4645/1 "2011-06-17T08:30:16Z")

</div>

Hi!

I need to find out where exactly search queries I run match in the  
indexed documents, in order to highlight these positions; like, if I  
search for "squirrel", i'd like to highlight that term in the search  
results. I can do this with basic string search for term queries, but  
I'd be curious if ElasticSearch offers anything to faciliate doing  
this with span near queries etc., having to duplicate ElasticSearch's  
pattern matching would be rather cumbersome.

Thanks!

Felix

---

<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, 4:03am UTC](https://discuss.elastic.co/t/finding-out-offsets-of-query-matches-in-indexed-text/4645/2 "2017-07-06T04:03:16Z")

</div>


