# Cannot use custom analyzer for keyword

**URL:** <https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813>\
**Category:** Elasticsearch\
**Created:** [August 4, 2017, 4:50am UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813 "2017-08-04T04:50:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![3white](https://avatars.discourse-cdn.com/v4/letter/3/46a35a/32.png) [@3white](https://discuss.elastic.co/u/3white)\
**Post date:** [August 4, 2017, 4:50am UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813/1 "2017-08-04T04:50:35Z")

</div>

I am trying to use a simple custom analyzer (a char filter and keyword tokeniser) to build a keyword field.

However when I specify the analyzer besides with type : "keyword", ES said not supported analyzer field.

If I switch to type : "text" , and index can be created without problem, but when index data , it complained that mapper [message.keyword] cannot be changed from type [text] to [keyword]

I am using ES 5.1.1

And following is my index setting :

> {  
> "settings": {  
> "analysis": {  
> "analyzer": {  
> "log\_message\_keyword": {  
> "tokenizer": "keyword",  
> "char\_filter": [  
> "strip\_digits"  
> ]  
> }  
> },  
> "char\_filter": {  
> "strip\_digits": {  
> "type": "pattern\_replace",  
> "pattern": "(\d+)",  
> "replacement": "N"  
> }  
> }  
> }  
> },  
> "mappings": {  
> "log": {  
> "properties": {  
> "message": {  
> "type": "text",  
> "fields": {  
> "keyword": {  
> "type": "text",  
> "analyzer": "log\_message\_keyword",  
> }  
> }  
> }  
> }}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 4, 2017, 6:57am UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813/2 "2017-08-04T06:57:25Z")

</div>

Take a look at normalizers

[https://www.elastic.co/guide/en/elasticsearch/reference/5.5/analysis-normalizers.html#\_custom\_normalizers](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/analysis-normalizers.html#_custom_normalizers)

---

<div class="post-metadata">

**Author:** ![3white](https://avatars.discourse-cdn.com/v4/letter/3/46a35a/32.png) [@3white](https://discuss.elastic.co/u/3white)\
**Post date:** [August 4, 2017, 6:47pm UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813/3 "2017-08-04T18:47:44Z")

</div>

Good point, but are this feature available for 5.1 ? I didn't see if in 5.1 doc

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 6, 2017, 8:50pm UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813/4 "2017-08-06T20:50:05Z")

</div>

It was IIRC introduced in 5.2.

---

<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:** [September 3, 2017, 8:50pm UTC](https://discuss.elastic.co/t/cannot-use-custom-analyzer-for-keyword/95813/5 "2017-09-03T20:50:38Z")

</div>

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