# Case-insensitive term query

**URL:** <https://discuss.elastic.co/t/case-insensitive-term-query/69810>\
**Category:** Elasticsearch\
**Created:** [December 22, 2016, 2:57pm UTC](https://discuss.elastic.co/t/case-insensitive-term-query/69810 "2016-12-22T14:57:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars2](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Lars2](https://discuss.elastic.co/u/Lars2)\
**Post date:** [December 22, 2016, 2:57pm UTC](https://discuss.elastic.co/t/case-insensitive-term-query/69810/1 "2016-12-22T14:57:02Z")

</div>

Hey, i want to search my records case insensitive. I have the following mapping in my field:

```
"name": {
                    "type": "string",
                    "analyzer": "lowercase_analyzer"
                  },

```

Where lowercase\_analyzer is:

```
"settings": {
    "analysis": {
      "analyzer": {
        "lowercase_analyzer": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase"
          ]
        }
      }
    }
  }

```

If i now search on my name with anything else as lowercase, it does not find my records.

Is there anyway to have a case insensitive mapping?

---

<div class="post-metadata">

**Author:** ![geppo](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@geppo](https://discuss.elastic.co/u/geppo)\
**Post date:** [December 22, 2016, 5:42pm UTC](https://discuss.elastic.co/t/case-insensitive-term-query/69810/2 "2016-12-22T17:42:44Z")

</div>

yes, you have to change your tokenizer from keyword to whitespace or standard, you can also set your language rules [https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lang-analyzer.html) . keyword tokenizer, as described in documentation [https://www.elastic.co/guide/en/elasticsearch/reference/5.0//analysis-keyword-tokenizer.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.0//analysis-keyword-tokenizer.html), take all the terms in that field and make them a single token, a keyword. This setting is useful when you index fields with few but significant words(es. New York and New Mexico as a single token, a code like ak234, as a single token,etc.

---

<div class="post-metadata">

**Author:** ![Lars2](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Lars2](https://discuss.elastic.co/u/Lars2)\
**Post date:** [December 23, 2016, 8:16am UTC](https://discuss.elastic.co/t/case-insensitive-term-query/69810/3 "2016-12-23T08:16:02Z")

</div>

Thanks for the reply.

The problem is that i still need to take all the terms and make them a single token. but i also need it to be case insensitive. is that possible?

---

<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:** [January 20, 2017, 8:16am UTC](https://discuss.elastic.co/t/case-insensitive-term-query/69810/4 "2017-01-20T08:16:09Z")

</div>

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