# Analyzer for generating keywords

**URL:** <https://discuss.elastic.co/t/analyzer-for-generating-keywords/9625>\
**Category:** Elasticsearch\
**Created:** [November 8, 2012, 8:53am UTC](https://discuss.elastic.co/t/analyzer-for-generating-keywords/9625 "2012-11-08T08:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://discuss.elastic.co/u/Anton)\
**Post date:** [November 8, 2012, 8:53am UTC](https://discuss.elastic.co/t/analyzer-for-generating-keywords/9625/1 "2012-11-08T08:53:54Z")

</div>

Hi all,

I have a potentially stupid noob question about analyzers.

Is it possible to create an analyzer to populate a specified field in all  
records automatically? Specifically, I want to create a field with keywords  
based on a text field in that same record. I want to be able to do a check  
on which keywords were generated for each record, to verify what the  
analyzer is doing. Or do analyzers only work on indexing, and the results  
can't be inspected directly?

Also, when an analyzer is applied to an index, does this also apply to  
existing records, or do these records need to be reindexed? If so, how is  
the reindexing triggered?

Thanks!

--

---

<div class="post-metadata">

**Author:** ![simonw\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simonw_2/32/1130_2.png) [@simonw\_2](https://discuss.elastic.co/u/simonw_2)\
**Post date:** [November 8, 2012, 9:44am UTC](https://discuss.elastic.co/t/analyzer-for-generating-keywords/9625/2 "2012-11-08T09:44:45Z")

</div>

Hey Anton,

On Thursday, November 8, 2012 9:53:54 AM UTC+1, Anton wrote:

> Hi all,
> 
> I have a potentially stupid noob question about analyzers.

In general an analyzer is usually used per field and the analyzer is used  
at index and at query time. So if you index a document elasticsearch  
chooses an analyzer and passes your text through the analyzer. The created  
tokens are then used to build the inverted index (  
[Inverted index - Wikipedia](http://en.wikipedia.org/wiki/Inverted_index)). At query time the same thing  
happens, we pass the text through the analyzer and build the query based on  
the created tokens.

> Is it possible to create an analyzer to populate a specified field in all  
> records automatically? Specifically, I want to create a field with keywords  
> based on a text field in that same record. I want to be able to do a check  
> on which keywords were generated for each record, to verify what the  
> analyzer is doing. Or do analyzers only work on indexing, and the results  
> can't be inspected directly?

I am not sure if I understand this question. Each field in ES can have its  
own index / query analyzer and you can configure which field uses which  
analyzer via the mapping API. (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/)) The analyzers can  
also be defined freely via a REST endpoint when you create the index (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/)).

> Also, when an analyzer is applied to an index, does this also apply to  
> existing records, or do these records need to be reindexed? If so, how is  
> the reindexing triggered?

you can't change your analyzers once they have been configured otherwise we  
would need to entriely reindex and that is sometimes not possible ie. if we  
need the data from a 3rd party resource. you should configure your analysis  
ahead of time. Yet, if you want to get more insight into what happens when  
you pass a certain string to ES you can checkout the analyze API (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html))  
that basically applies an analyzer to text and returns you the result as a  
json response.

simon

> Thanks!

--

---

<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:05am UTC](https://discuss.elastic.co/t/analyzer-for-generating-keywords/9625/3 "2017-07-06T03:05:28Z")

</div>


