# How to make search using keyword field with ignorecase

**URL:** <https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419>\
**Category:** Kibana\
**Created:** [September 22, 2017, 5:56am UTC](https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419 "2017-09-22T05:56:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanchan](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@kanchan](https://discuss.elastic.co/u/kanchan)\
**Post date:** [September 22, 2017, 5:56am UTC](https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419/1 "2017-09-22T05:56:49Z")

</div>

Hi,  
I am using keyword field for exact match.but it is case sensetive.how could i make it case insensetive.  
code which I use for searching is:

GET /ciq/\_search  
{

"query": {  
"bool": {  
"must": [  
{  
"match": {  
"companyname.keyword": {  
"query": "SHELL PRIVATE LTD",  
"analyzer": "coal\_asset\_text\_general\_likely"  
}  
}  
}  
]  
}  
}  
}

it is not giving records where company name in lowercase.how could i make it possible.

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [September 22, 2017, 10:54pm UTC](https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419/2 "2017-09-22T22:54:50Z")

</div>

You will need to use a custom normalizer, for example:

```auto
PUT ciq
{
  "settings": {
    "analysis": {
      "normalizer": {
        "lowercase_normalizer": {
          "type": "custom",
          "char_filter": [],
          "filter": ["lowercase"]
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "companyname.keyword": {
          "type": "keyword",
          "normalizer": "lowercase_normalizer"
        }
      }
    }
  }
}

POST ciq/doc
{
  "companyname.keyword": "foo"
}

POST ciq/doc
{
  "companyname.keyword": "Foo"
}

GET /ciq/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "companyname.keyword": {
              "query": "foo"
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![kanchan](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@kanchan](https://discuss.elastic.co/u/kanchan)\
**Post date:** [September 25, 2017, 11:38am UTC](https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419/3 "2017-09-25T11:38:26Z")

</div>

ok. but if I will search for exact match for lowercase foo, it will only show ''foo'' as doc but my requirement is It should match only letter not case.  
suppose if I query for foo or Foo, it should show both docs.

How can I achieve it using keyword field.

---

<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:** [October 23, 2017, 11:38am UTC](https://discuss.elastic.co/t/how-to-make-search-using-keyword-field-with-ignorecase/101419/4 "2017-10-23T11:38:30Z")

</div>

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