# How to define the analyzer when creating index?

**URL:** <https://discuss.elastic.co/t/how-to-define-the-analyzer-when-creating-index/23536>\
**Category:** Elasticsearch\
**Created:** [May 4, 2015, 10:27am UTC](https://discuss.elastic.co/t/how-to-define-the-analyzer-when-creating-index/23536 "2015-05-04T10:27:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhulin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhulin/32/44934_2.png) [@zhulin](https://discuss.elastic.co/u/zhulin)\
**Post date:** [May 4, 2015, 10:27am UTC](https://discuss.elastic.co/t/how-to-define-the-analyzer-when-creating-index/23536/1 "2015-05-04T10:27:06Z")

</div>

How to define a analyzer for an index, not just field?

It seems by default it will not using the default analyzer I defined in  
elasticsearch.yml.  
index.analysis.analyzer.default.type: ik

If I request:  
[http://localhost:9200/useridx/\_search?q=Lin](http://localhost:9200/useridx/_search?q=Lin) it doesn't using the default  
analyzer.

And this works:  
[http://localhost:9200/useridx/\_search?analyzer=ik&q=Lin](http://localhost:9200/useridx/_search?analyzer=ik&q=Lin)

Do we need each query time set the analyzer?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7b6c3368-d8b4-4178-9a55-d49a0461b1c3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7b6c3368-d8b4-4178-9a55-d49a0461b1c3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![zhulin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhulin/32/44934_2.png) [@zhulin](https://discuss.elastic.co/u/zhulin)\
**Post date:** [May 4, 2015, 10:42am UTC](https://discuss.elastic.co/t/how-to-define-the-analyzer-when-creating-index/23536/2 "2015-05-04T10:42:29Z")

</div>

At search time, the  
[http://www.elastic.co/guide/en/elasticsearch/guide/master/\_controlling\_analysis.html#id-1.5.4.12.18.5.1](http://www.elastic.co/guide/en/elasticsearch/guide/master/_controlling_analysis.html#id-1.5.4.12.18.5.1)  
[http://www.elastic.co/guide/en/elasticsearch/guide/master/\_controlling\_analysis.html#id-1.5.4.12.18.5.2](http://www.elastic.co/guide/en/elasticsearch/guide/master/_controlling_analysis.html#id-1.5.4.12.18.5.2)sequence  
is slightly different:

- _The analyzer defined in the query itself, else_
- The analyzer defined in the field mapping, else
- The default analyzer for the type, which defaults to
- The analyzer named default in the index settings, which defaults to
- The analyzer named default at node level, which defaults to
- The standard analyzer

I notice this, but I haven't define analyzer in field mapping, or for some  
type and index.

在 2015年5月4日星期一 UTC+8下午6:27:06，Lin Zhu写道：

> How to define a analyzer for an index, not just field?
> 
> It seems by default it will not using the default analyzer I defined in  
> elasticsearch.yml.  
> index.analysis.analyzer.default.type: ik
> 
> If I request:  
> [http://localhost:9200/useridx/\_search?q=Lin](http://localhost:9200/useridx/_search?q=Lin) it doesn't using the default  
> analyzer.
> 
> And this works:  
> [http://localhost:9200/useridx/\_search?analyzer=ik&q=Lin](http://localhost:9200/useridx/_search?analyzer=ik&q=Lin)
> 
> Do we need each query time set the analyzer?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e184e670-e8e9-42f8-afc0-092c8363e9b6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e184e670-e8e9-42f8-afc0-092c8363e9b6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:15am UTC](https://discuss.elastic.co/t/how-to-define-the-analyzer-when-creating-index/23536/3 "2017-07-06T00:15:54Z")

</div>


