# How to get tokens for a document?

**URL:** https://discuss.elastic.co/t/how-to-get-tokens-for-a-document/110083
**Category:** Elasticsearch
**Created:** [December 4, 2017, 3:06am UTC](https://discuss.elastic.co/t/how-to-get-tokens-for-a-document/110083 "2017-12-04T03:06:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![VidyVideni](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@VidyVideni](https://discuss.elastic.co/u/VidyVideni)
#### Post date: [December 4, 2017, 3:06am UTC](https://discuss.elastic.co/t/how-to-get-tokens-for-a-document/110083/1 "2017-12-04T03:06:28Z")

</div>

I need to get all tokens for a document when debug, so I know what exact tokens indexed in elasticsearch , this can help me understand why a query doesn't get any result when it supposed to be . any way to do this please?

---

<div class="post-metadata">

### Author: ![effendisusanto](https://avatars.discourse-cdn.com/v4/letter/e/87869e/32.png) [@effendisusanto](https://discuss.elastic.co/u/effendisusanto)
#### Post date: [December 5, 2017, 5:12am UTC](https://discuss.elastic.co/t/how-to-get-tokens-for-a-document/110083/2 "2017-12-05T05:12:40Z")

</div>

Hi Vidy,

Yesterday I asked the same question, you can read the answer on the elasticsearch guide,

[https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html)

Based on that guide, you can retrive the token on document by the following query :

GET /twitter/tweet/1/\_termvectors  
{  
"fields" : ["text"],  
"offsets" : true,  
"payloads" : true,  
"positions" : true,  
"term\_statistics" : true,  
"field\_statistics" : true  
}

Hope it save your night 😃

---

<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: [January 2, 2018, 5:12am UTC](https://discuss.elastic.co/t/how-to-get-tokens-for-a-document/110083/3 "2018-01-02T05:12:59Z")

</div>

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