# Start and end offset of a token in elasticsearch

**URL:** <https://discuss.elastic.co/t/start-and-end-offset-of-a-token-in-elasticsearch/470>\
**Category:** Elasticsearch\
**Created:** [May 11, 2015, 5:10am UTC](https://discuss.elastic.co/t/start-and-end-offset-of-a-token-in-elasticsearch/470 "2015-05-11T05:10:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khodaei\_reza](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@khodaei\_reza](https://discuss.elastic.co/u/khodaei_reza)\
**Post date:** [May 11, 2015, 5:10am UTC](https://discuss.elastic.co/t/start-and-end-offset-of-a-token-in-elasticsearch/470/1 "2015-05-11T05:10:21Z")

</div>

Hi friends.

I want to obtain offsets of a token in it's own document in Elasticsearch.

TermVector method can give this information, but i don't want to have the termvector of a document, because it maybe be very large for transferring through a restful service.

Thanks.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [May 11, 2015, 7:39am UTC](https://discuss.elastic.co/t/start-and-end-offset-of-a-token-in-elasticsearch/470/2 "2015-05-11T07:39:31Z")

</div>

I don't think there are other ways. For the record, getting offsets tends to be error-prone as these offsets depend on the encoding which is being used, so if you are not using ASCII you might have surprises. The offsets that elasticsearch returns are computed on the UTF16-encoded string (which is Java's internal string encoding).

---

<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, 12:14am UTC](https://discuss.elastic.co/t/start-and-end-offset-of-a-token-in-elasticsearch/470/3 "2017-07-06T00:14:40Z")

</div>


