# Case insensitive search on not analyzed fields

**URL:** <https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128>\
**Category:** Elasticsearch\
**Created:** [August 16, 2016, 12:04pm UTC](https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128 "2016-08-16T12:04:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea\_patricelli](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@andrea\_patricelli](https://discuss.elastic.co/u/andrea_patricelli)\
**Post date:** [August 16, 2016, 12:04pm UTC](https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128/1 "2016-08-16T12:04:59Z")

</div>

Hi,

I googled about case sensitivity of ES searches and got this:

1. "You'll need to analyze a field to search case-insensitive."
2. "If you want to make a case insensitive search you should use match query"

Are 1 and 2 correct?

and moreover my question

1. Is there a way to make case INsensitive search on not analyzed string fields? Or do I've do use an analyzer with lowercase tokenizer (simple for example)?

Thanks for your help!

---

<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:** [August 16, 2016, 1:05pm UTC](https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128/2 "2016-08-16T13:05:15Z")

</div>

You'd use the `keyword` tokenizer with a `lowercase` token filter and a match query, yes.

You could also lowercase the field on the way in, maybe with an ingest pipeline (whenever 5.0 is ready) and then use a `match` query with an analyzer that uses the `keyword` tokenizer and the `lowercase` token filter. The advantage of this way is that you can still use field data with the field. Though, early in 5.0 (like 5.1 or 5.2), `keyword` fields will be able to use field data anyway so it might be moot.

There are other much less efficient, much more labor intensive ways to do it like making a plugin that turns one query into the union of a zillion (`2^length`) queries which permute the case. Or something in between.

There are always tradeoffs and the standard way of doing things with Elasticsearch almost always goes with the "use more time and space for indexing to make searching faster".

---

<div class="post-metadata">

**Author:** ![andrea\_patricelli](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@andrea\_patricelli](https://discuss.elastic.co/u/andrea_patricelli)\
**Post date:** [August 16, 2016, 3:16pm UTC](https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128/3 "2016-08-16T15:16:59Z")

</div>

Thanks a lot for the answer!

So match query does not guarantees case INsensitivity on its own. I have to set an analyzer on the field that I want to match as case-insensitive. Am I right?

---

<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:27pm UTC](https://discuss.elastic.co/t/case-insensitive-search-on-not-analyzed-fields/58128/4 "2017-07-05T22:27:32Z")

</div>


