# Getting offsets of a keyword in documents

**URL:** <https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172>\
**Category:** Elasticsearch\
**Created:** [January 30, 2017, 9:26am UTC](https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172 "2017-01-30T09:26:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumar\_ts](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kumar\_ts](https://discuss.elastic.co/u/kumar_ts)\
**Post date:** [January 30, 2017, 9:26am UTC](https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172/1 "2017-01-30T09:26:29Z")

</div>

I'm new to Elasticsearch. I have created an index named "files". Then I have added a document with fields 'name' & 'content', under the type "text". like below.  
curl -XPUT 'localhost:9200/files/text/1?pretty' -H 'Content-Type: application/json' -d'  
{  
"name" : "Readme",  
"content" : "Hi this is a sample document.I created this document to explore the features of elasticsearch"  
}'

I want to search in the 'content' field of this document for a keyword [for eg.'this'] and get its offsets. Is it possible ?. Actually my requirement is to get the offsets of a keyword in 'n' documents in an index

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [January 30, 2017, 9:40am UTC](https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172/2 "2017-01-30T09:40:40Z")

</div>

Hi, maybe you can look at this : [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html)

---

<div class="post-metadata">

**Author:** ![kumar\_ts](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kumar\_ts](https://discuss.elastic.co/u/kumar_ts)\
**Post date:** [January 30, 2017, 10:46am UTC](https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172/3 "2017-01-30T10:46:14Z")

</div>

thanks. I tried it. but it only highlights the occurrences. I want its offsets .

---

<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:** [February 27, 2017, 10:46am UTC](https://discuss.elastic.co/t/getting-offsets-of-a-keyword-in-documents/73172/4 "2017-02-27T10:46:41Z")

</div>

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