# Retrieving Analyzer Tokens

**URL:** <https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964>\
**Category:** Elasticsearch\
**Created:** [March 11, 2012, 11:13pm UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964 "2012-03-11T23:13:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratawing](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@stratawing](https://discuss.elastic.co/u/stratawing)\
**Post date:** [March 11, 2012, 11:13pm UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/1 "2012-03-11T23:13:56Z")

</div>

Is there any way to return the actual tokens generated by an  
index\_analyzer at search time? I am using the synonyms filter  
(without expansion) to index a particular field, and would like to get  
the standardized value (right-hand-side of the "=\>" in my synonyms  
file ) for each document that was retrieved.

synonym file includes, for example:

i-pod, i pod =\> ipod,

when user searches for "i-pod" or "i pod", I want to return the  
indexed doc, but also want to return "ipod" as the token that was  
created at index time as part of the analysis.

I have my synonyms analyzer up and running, and can get the proper  
tokens using the Analyze API.

Many thanks in advance for your thoughts and time.

Cheers!

---

<div class="post-metadata">

**Author:** ![stratawing](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@stratawing](https://discuss.elastic.co/u/stratawing)\
**Post date:** [March 12, 2012, 2:47am UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/2 "2012-03-12T02:47:38Z")

</div>

Here's a gist of the key pieces of my mapping, synonyms file, and a  
note on my desired output - in case it helps.

> <https://gist.github.com/stratawing/2019391>

---

<div class="post-metadata">

**Author:** ![stratawing](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@stratawing](https://discuss.elastic.co/u/stratawing)\
**Post date:** [March 12, 2012, 6:41pm UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/3 "2012-03-12T18:41:27Z")

</div>

I've read a bit on Lucene tokens since yesterday, and it doesn't seem  
possible to recover the tokens without using something like  
[http://lucene.apache.org/core/old\_versioned\_docs/versions/3\_0\_0/api/core/index.html?org/apache/lucene/index/IndexReader.html](http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/api/core/index.html?org/apache/lucene/index/IndexReader.html)

Is this correct?

---

<div class="post-metadata">

**Author:** ![stratawing](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@stratawing](https://discuss.elastic.co/u/stratawing)\
**Post date:** [March 14, 2012, 12:03am UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/4 "2012-03-14T00:03:44Z")

</div>

Wow. Bummer. Zero responses.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 14, 2012, 12:27pm UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/5 "2012-03-14T12:27:20Z")

</div>

How about using the analyze API?

On Wednesday, March 14, 2012 at 2:03 AM, stratawing wrote:

> Wow. Bummer. Zero responses.

---

<div class="post-metadata">

**Author:** ![stratawing](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@stratawing](https://discuss.elastic.co/u/stratawing)\
**Post date:** [March 14, 2012, 1:50pm UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/6 "2012-03-14T13:50:38Z")

</div>

Thanks Shay! - I was hoping to get the actual doc returned together  
with the tokens.  
Not really mission critical. I'll fiddle around with the analyze api  
a bit more to see if I can get the desired output.

On Mar 14, 8:27 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> How about using the analyze API?
> 
> On Wednesday, March 14, 2012 at 2:03 AM, stratawing wrote:
> 
> > Wow. Bummer. Zero responses.

---

<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, 3:36am UTC](https://discuss.elastic.co/t/retrieving-analyzer-tokens/6964/7 "2017-07-06T03:36:09Z")

</div>


