# Elasticsearch case insensitive to not\_analyzed index

**URL:** <https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979>\
**Category:** Elasticsearch\
**Created:** [June 16, 2016, 11:03am UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979 "2016-06-16T11:03:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarlok](https://avatars.discourse-cdn.com/v4/letter/t/13edae/32.png) [@tarlok](https://discuss.elastic.co/u/tarlok)\
**Post date:** [June 16, 2016, 11:03am UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/1 "2016-06-16T11:03:04Z")

</div>

Hi,

I am using not\_analyzed index for performing exact word search but not\_analyzed index make search case sensitive. I also tried analyzer setting:

"settings" : {  
"index" : {  
"creation\_date" : "1466062045942",  
"analysis" : {  
"analyzer" : {  
"analyzer\_keyword" : {  
"filter" : ["lowercase"],  
"type" : "custom",  
"tokenizer" : "keyword"  
}  
}  
},  
"number\_of\_shards" : "5",  
"number\_of\_replicas" : "1",  
"uuid" : "kx7We-gRSGCXU1u6PZF5xQ",  
"version" : {  
"created" : "2030199"  
}  
}

But it doesn't work.  
Please help me to make search exact word and case-insensitive.

Thanks  
Tarlok

---

<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:** [June 16, 2016, 1:00pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/2 "2016-06-16T13:00:09Z")

</div>

Hey,

please create full reproduction of the steps that you did. The above snippet does have any information where you used that analyzer in your mapping, as you need to conifgure it for the field you want to use it for.

--Alex

---

<div class="post-metadata">

**Author:** ![tarlok](https://avatars.discourse-cdn.com/v4/letter/t/13edae/32.png) [@tarlok](https://discuss.elastic.co/u/tarlok)\
**Post date:** [June 16, 2016, 2:21pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/3 "2016-06-16T14:21:12Z")

</div>

Hi Alexander,

I have mapped fields to not\_analyzed index as I want exact word search. Below is mapping :

"mappings" : {  
"tweet" : {  
"properties" : {  
"Message" : {  
"type" : "string"  
"index" : "not\_analyzed"  
},  
"User" : {  
"type" : "string"  
"index" : "not\_analyzed"  
}  
}  
}  
}

Analyzer setting is:

"settings" : {  
"index" : {  
"creation\_date" : "1466062045942",  
"analysis" : {  
"analyzer" : {  
"analyzer\_keyword" : {  
"filter" : ["lowercase"],  
"type" : "custom",  
"tokenizer" : "keyword"  
}  
}  
},  
"number\_of\_shards" : "5",  
"number\_of\_replicas" : "1",  
"uuid" : "kx7We-gRSGCXU1u6PZF5xQ",  
"version" : {  
"created" : "2030199"  
}  
}

Then I am making query to get exact word search:

"filter": { "or": [{ "term": { "User": "Test" } },{ "term": { "Message": "Test" } }] }

It is working fine but when I am trying with "test" the it is returning 0 result. So basically case-insensitive search is not working for exact word.

Please let me know if there is a way to achieve this.

Thanks  
Tarlok

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [June 16, 2016, 2:27pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/4 "2016-06-16T14:27:18Z")

</div>

Hi @tarlok,

somebody asked the exact same question just two days ago. Please check the [related thread](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/13).

Daniel

---

<div class="post-metadata">

**Author:** ![tarlok](https://avatars.discourse-cdn.com/v4/letter/t/13edae/32.png) [@tarlok](https://discuss.elastic.co/u/tarlok)\
**Post date:** [June 16, 2016, 2:47pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/5 "2016-06-16T14:47:01Z")

</div>

Hi Daniel,

Thanks for your suggestion. Performance is very important in our application. We are changing from solr to elastic because of performance. So I don't want to slow down performance. Please let me know if there is any other solution for this.

Thanks  
Tarlok

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [June 16, 2016, 2:57pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/6 "2016-06-16T14:57:31Z")

</div>

Hi @tarlok,

the suggested approach is to use multiple fields as I [suggested in my first answer in that post](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/2?u=danielmitterdorfer). Queries will be fast then but of course the additional field will require additional disk space in the index.

Daniel

---

<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:** [June 16, 2016, 3:02pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/7 "2016-06-16T15:02:55Z")

</div>

Hey,

you are not using the defined `analyzer_keyword` in your mapping for any of the fields, so it never gets applied. See [the analyzer documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html)

--Alex

---

<div class="post-metadata">

**Author:** ![tarlok](https://avatars.discourse-cdn.com/v4/letter/t/13edae/32.png) [@tarlok](https://discuss.elastic.co/u/tarlok)\
**Post date:** [June 17, 2016, 7:36am UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/8 "2016-06-17T07:36:16Z")

</div>

Hi Daniel/Alexander,

Thanks for your help. It is working fine now 😄 .

My setting is:  
"settings" : {  
"index" : {  
"creation\_date" : "1466141139185",  
"analysis" : {  
"analyzer" : {  
"case\_insensitive" : {  
"filter" : ["lowercase"],  
"type" : "custom",  
"tokenizer" : "keyword"  
}  
}  
},  
"number\_of\_shards" : "5",  
"number\_of\_replicas" : "1",  
"uuid" : "htjDOddeTTO2JC33BZ6fmQ",  
"version" : {  
"created" : "2030199"  
}  
}  
}

My mapping is:  
"mappings" : {  
"tweet" : {  
"dynamic" : "false",  
"\_all" : {  
"enabled" : false  
},  
"properties" : {  
"Message" : {  
"type" : "string",  
"analyzer" : "case\_insensitive"  
},  
"User" : {  
"type" : "string",  
"analyzer" : "case\_insensitive"  
}  
}  
}  
}

I am just converting user input to lower-case. Below is my query:  
"filter": { "or": [{ "term": { "User": "test" } },{ "term": { "Message": "test" } }] }

This query shows exact word result with case-insensitivity.

Thanks  
Tarlok

---

<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 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/elasticsearch-case-insensitive-to-not-analyzed-index/52979/9 "2017-07-05T22:42:52Z")

</div>


