# Searching not analyzed term name and value in case insensitive manner

**URL:** <https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537>\
**Category:** Elasticsearch\
**Created:** [May 20, 2016, 7:51am UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537 "2016-05-20T07:51:38Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![charyorde](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@charyorde](https://discuss.elastic.co/u/charyorde)\
**Post date:** [May 2, 2017, 9:08am UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/21 "2017-05-02T09:08:08Z")

</div>

@danielmitterdorfer By applying the keyword tokenizer, are we still guaranteed an exact match in the search result?

---

<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:** [May 2, 2017, 12:57pm UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/22 "2017-05-02T12:57:40Z")

</div>

Hi @charyorde,

I am not sure what you mean by that. Can you please provide a concrete example?

Daniel

---

<div class="post-metadata">

**Author:** ![charyorde](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@charyorde](https://discuss.elastic.co/u/charyorde)\
**Post date:** [May 2, 2017, 1:22pm UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/23 "2017-05-02T13:22:28Z")

</div>

@danielmitterdorfer . Thanks for writing. I want to achieve exact match in search as well as maintain case insensitivity. So I'm wondering whether this makes sense.  
`{ "settings": { "analysis": { "analyzer": { "case_insensitive": { "tokenizer": "keyword", "filter": ["lowercase"] } } } }, "mappings" : { "pages" : { "properties" : { "firstname" : { "type" : "string", "index": "not_analyzed", "analyzer": "case_insensitive" } } } } }`

If I remove `"index": "not_analyzed"`, am I still guaranteed an exact match in the search result?

---

<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:** [May 2, 2017, 1:50pm UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/24 "2017-05-02T13:50:17Z")

</div>

Hi @charyorde,

you are adding an analyzer to a `not_analyzed` field. This cannot work. I checked the behavior of Elasticsearch 2.4.4 and it happily accepts these settings in the create index request. However, it simply ignores your analyzer and treats the field as `not_analyzed`. Just try this:

```auto
PUT /my_index
{
   "settings": {
      "analysis": {
         "analyzer": {
            "case_insensitive": {
               "tokenizer": "keyword",
               "filter": [
                  "lowercase"
               ]
            }
         }
      }
   },
   "mappings": {
      "my_type": {
         "properties": {
            "name": {
               "type": "string",
               "index": "not_analyzed", 
               "analyzer": "case_insensitive"
            }
         }
      }
   }
}

```

Then do `GET /my_index/_mapping` and you'll see that Elasticsearch simply ignores your analyzer:

```auto
{
   "my_index": {
      "mappings": {
         "my_type": {
            "properties": {
               "name": {
                  "type": "string",
                  "index": "not_analyzed"
               }
            }
         }
      }
   }
}

```

I suggest you play around with the [example that I've provided in my initial response](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/2), go through the thread and decide what fits your use-case best (I have a feeling that the mapping that I've provided in my initial response fits your use-case).

Daniel

---

<div class="post-metadata">

**Author:** ![charyorde](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@charyorde](https://discuss.elastic.co/u/charyorde)\
**Post date:** [May 2, 2017, 2:43pm UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/25 "2017-05-02T14:43:49Z")

</div>

Got it. 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:** [July 5, 2017, 10:00pm UTC](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537/26 "2017-07-05T22:00:43Z")

</div>

Closed on July 5, 2017, 10:00pm UTC



[Previous page](https://discuss.elastic.co/t/searching-not-analyzed-term-name-and-value-in-case-insensitive-manner/50537.md?page=1)
