# Questions about analayzer

**URL:** <https://discuss.elastic.co/t/questions-about-analayzer/8475>\
**Category:** Elasticsearch\
**Created:** [July 20, 2012, 8:03am UTC](https://discuss.elastic.co/t/questions-about-analayzer/8475 "2012-07-20T08:03:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ywtsang](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@ywtsang](https://discuss.elastic.co/u/ywtsang)\
**Post date:** [July 20, 2012, 8:03am UTC](https://discuss.elastic.co/t/questions-about-analayzer/8475/1 "2012-07-20T08:03:04Z")

</div>

I have some questions about analyzer:

1. How can we we check which the analyzer is used in analyzing each  
field during indexing?

2. by checking the QueryStringQueryBuilder, the default analyzer used  
is "smart search analyzer" and so I have this problem:

the query string contains some words that are not be stripped away by  
"smart search analyzer" but the words are stripped away by the  
"default" analyzer used to index and analyze the fields, that leads to  
searching for some words will yield no result

and I tried to set the QueryStringQueryBuilder to "standard" (I just  
guessed the default analyzer is standard, that's why I asked the  
question 1 above) and I can search the result

so, is there any problem to change from "smart" to "standard" analyzer?

or is there any documentation that can help to understand the logic of  
different analyzers?

Thanks,  
Wing

---

<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:** [July 20, 2012, 3:01pm UTC](https://discuss.elastic.co/t/questions-about-analayzer/8475/2 "2012-07-20T15:01:21Z")

</div>

hey,

On Friday, July 20, 2012 10:03:04 AM UTC+2, Yiu Wing TSANG wrote:

> I have some questions about analyzer:
> 
> 1. How can we we check which the analyzer is used in analyzing each  
> field during indexing?

check your field mapping if you didn't provide any mapping for the field  
standard should be used for both indexing and searching.

you can explicitly define a search / index analyzer in the mapping per  
field:

"index\_analyzer" : "standard",  
"search\_analyzer" : "your\_super\_smart\_analyzer"

see  
this: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html)

> 1. by checking the QueryStringQueryBuilder, the default analyzer used  
> is "smart search analyzer" and so I have this problem:

> the query string contains some words that are not be stripped away by  
> "smart search analyzer" but the words are stripped away by the  
> "default" analyzer used to index and analyze the fields, that leads to  
> searching for some words will yield no result

just use your smart analyzer at index and search time or the other way  
around?

> and I tried to set the QueryStringQueryBuilder to "standard" (I just  
> guessed the default analyzer is standard, that's why I asked the  
> question 1 above) and I can search the result
> 
> so, is there any problem to change from "smart" to "standard" analyzer?

if you change the the query side analyzer to be the same as the index time  
analyzer you don't have any problems i'd say. if you have different  
analyzers at search and index time you just need to make sure they are  
compatible. ie. you can use synonyms at query time OR at index time and  
keep the rest of the analyzer the same. does that make sense?

> or is there any documentation that can help to understand the logic of  
> different analyzers?

you can check the lucene documenation for analyzers ie. java books or read  
lucene in action (good reading anyway) there is no tutorial like  
documentation for it around. (at least that I know of)

simon

> Thanks,  
> Wing

---

<div class="post-metadata">

**Author:** ![ywtsang](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@ywtsang](https://discuss.elastic.co/u/ywtsang)\
**Post date:** [July 23, 2012, 2:29am UTC](https://discuss.elastic.co/t/questions-about-analayzer/8475/3 "2012-07-23T02:29:33Z")

</div>

Thanks simon,

I can find the analyzer mapping configuration used by elasticsearch here:

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java)

So now I can read the details of each analyzer from lucene doc.

But I still cannot find the default "smart" search analyzer used by  
elasticsearch (ref: QueryStringQueryBuilder#analyzer).

Can you give me the pointer to the source code of the default "smart"  
search analyzer so that I can read the details myself?

Thanks,  
Wing

On Fri, Jul 20, 2012 at 11:01 PM, simonw  
[simon.willnauer@elasticsearch.com](mailto:simon.willnauer@elasticsearch.com) wrote:

> hey,
> 
> On Friday, July 20, 2012 10:03:04 AM UTC+2, Yiu Wing TSANG wrote:
> 
> > I have some questions about analyzer:
> > 
> > 1. How can we we check which the analyzer is used in analyzing each  
> > field during indexing?
> 
> check your field mapping if you didn't provide any mapping for the field  
> standard should be used for both indexing and searching.
> 
> you can explicitly define a search / index analyzer in the mapping per  
> field:
> 
> "index\_analyzer" : "standard",  
> "search\_analyzer" : "your\_super\_smart\_analyzer"
> 
> see this:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/root-object-type.html)
> 
> > 1. by checking the QueryStringQueryBuilder, the default analyzer used  
> > is "smart search analyzer" and so I have this problem:
> > 
> > the query string contains some words that are not be stripped away by  
> > "smart search analyzer" but the words are stripped away by the  
> > "default" analyzer used to index and analyze the fields, that leads to  
> > searching for some words will yield no result
> 
> just use your smart analyzer at index and search time or the other way  
> around?
> 
> > and I tried to set the QueryStringQueryBuilder to "standard" (I just  
> > guessed the default analyzer is standard, that's why I asked the  
> > question 1 above) and I can search the result
> > 
> > so, is there any problem to change from "smart" to "standard" analyzer?
> 
> if you change the the query side analyzer to be the same as the index time  
> analyzer you don't have any problems i'd say. if you have different  
> analyzers at search and index time you just need to make sure they are  
> compatible. ie. you can use synonyms at query time OR at index time and keep  
> the rest of the analyzer the same. does that make sense?
> 
> > or is there any documentation that can help to understand the logic of  
> > different analyzers?
> 
> you can check the lucene documenation for analyzers ie. java books or read  
> lucene in action (good reading anyway) there is no tutorial like  
> documentation for it around. (at least that I know of)
> 
> simon
> 
> > Thanks,  
> > Wing

---

<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:19am UTC](https://discuss.elastic.co/t/questions-about-analayzer/8475/4 "2017-07-06T03:19:29Z")

</div>


