# Case Insensitive search using match query for keyword

**URL:** <https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320>\
**Category:** Elasticsearch\
**Created:** [May 11, 2017, 2:25am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320 "2017-05-11T02:25:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 11, 2017, 2:25am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/1 "2017-05-11T02:25:32Z")

</div>

Hi,

I have multiple attributes stored in ES with keyword datatype. I was wondering if it is possible to perform a case in-sensitive search using a match query on these keyword fields?

Thanks.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [May 11, 2017, 2:37am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/2 "2017-05-11T02:37:54Z")

</div>

Have a look at the [normalizer](https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html) property. If you add a `lowercase` normalizer then you should get case insensitive search.

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 11, 2017, 2:41am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/3 "2017-05-11T02:41:30Z")

</div>

Thanks for your reply.

I have a couple of questions:

1. Does adding a custom normalizer affect storage or query performance?
2. If I have an index with a lot of keyword fields, can I add the normalizer at any time or do I have to create a new index with the correct mappings and reindex the data?

Thanks

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [May 11, 2017, 2:57am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/4 "2017-05-11T02:57:44Z")

</div>

> [@Rory](#):
>
> 1. Does adding a custom normalizer affect storage or query performance?

Storage will be the same but you would have to rebuild the index with the new normalizer.

This is the fastest way to do case insensitive search.

> [@Rory](#):
>
> 1. If I have an index with a lot of keyword fields, can I add the normalizer at any time or do I have to create a new index with the correct mappings and reindex the data?

You need to recreate the index after changing the normalizer because it'd build a different on disk structure. You may be able to use [dynamic templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html) to automatically configure the normalizer on your index.

---

<div class="post-metadata">

**Author:** ![Davood1659](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davood1659/32/47291_2.png) [@Davood1659](https://discuss.elastic.co/u/Davood1659)\
**Post date:** [May 11, 2017, 4:48am UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/5 "2017-05-11T04:48:26Z")

</div>

Hi,

I had this problem and use of normalizer property solved it, but it caused a new problem. I have highlighting feature in my query along side with case insensitive keyword search. When I included normalizer property in my mapping, highlighting has stopped working. Do you know why?

---

<div class="post-metadata">

**Author:** ![Rory](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@Rory](https://discuss.elastic.co/u/Rory)\
**Post date:** [May 11, 2017, 3:25pm UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/6 "2017-05-11T15:25:21Z")

</div>

Hi @nik9000, I was reading through the documentation for keyword datatype, and it says here[https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html) that normalizer is an experimental feature and might go away in a future release.

Am I looking at the wrong documentation or it is indeed the case? Is there a more stable way of achieving case insensitive search? Like converting the keyword to a text field and using a custom analyzer?

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:** [June 8, 2017, 3:36pm UTC](https://discuss.elastic.co/t/case-insensitive-search-using-match-query-for-keyword/85320/7 "2017-06-08T15:36:19Z")

</div>

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