title: ElasticSearch: Adding a normalizer for case-insensitive search on keyword
body: <p>I have a large ES index with dynamically created "keyword" fields. I need to enable case-insensitive search on these. I understand analyzer is not available for keyword fields, and normalizer is to be used for it: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-normalizers.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-normalizers.html</a></p>
  
  <p>Is there a way to dynamically add normalizers to fields/mappings? I am able to add an analyzer to existing text fields by closing the index, adding the analyzer and reopening the index. This does not seem to work on existing indexes while adding normalizers. Is there a way to do this other than creating another index to re-index all the data?</p>
  
  <p>Here are my steps:
  Create a test index with the lowercase normalizer:</p>
  
  <pre><code>curl -XPUT localhost:9200/ganesh_index/ -d '
  {
    "settings": {
      "analysis": {
        "normalizer": {
          "useLowercase": {
            "type": "custom",
            "filter": [ "lowercase" ]
          }
        }
      }
    },
    "mappings":{
       "ganesh_type":{
          "properties":{
             "title":{
                "normalizer":"useLowercase",
                "type":"keyword"
             }
          }
       }
    }
  }'
  </code></pre>
  
  <p>Now, I can insert and query as desired:</p>
  
  <pre><code>curl -X PUT localhost:9200/ganesh_index/ganesh_type/1 -d '{"title":"ThisFox.StatusCode1"}'
  curl -X PUT localhost:9200/ganesh_index/ganesh_type/2 -d '{"title":"ThisFox.StatusCode2"}'
  
  curl -X POST 'localhost:9200/ganesh_index/_search?pretty' -d '{"query": {"regexp":{"title": "this.*code1"}}}'
  {
    "took" : 24,
    "timed_out" : false,
    "_shards" : {
      "total" : 5,
      "successful" : 5,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : 1,
      "max_score" : 1.0,
      "hits" : [
        {
          "_index" : "ganesh_index",
          "_type" : "ganesh_type",
          "_id" : "1",
          "_score" : 1.0,
          "_source" : {
            "title" : "ThisFox.StatusCode1"
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>However, if my index already exists like so:</p>
  
  <pre><code>curl -X PUT localhost:9200/ganesh_index -d '
  {
    "settings": {
      "index": {
        "number_of_shards": 2,
        "number_of_replicas": 2
      }
    }
  }'
  </code></pre>
  
  <p>and I insert records, I am unable to add the normalizer later.</p>
  
  <pre><code>curl -XPUT localhost:9200/ganesh_index/?pretty -d '
  &gt; {
  &gt;   "settings": {
  &gt;     "analysis": {
  &gt;       "normalizer": {
  &gt;         "useLowercase": {
  &gt;           "type": "custom",
  &gt;           "filter": [ "lowercase" ]
  &gt;         }
  &gt;       }
  &gt;     }
  &gt;   },
  &gt;   "mappings":{
  &gt;      "ganesh_type":{
  &gt;         "properties":{
  &gt;            "title":{
  &gt;               "normalizer":"useLowercase",
  &gt;               "type":"keyword"
  &gt;            }
  &gt;         }
  &gt;      }
  &gt;   }
  &gt; }'
  {
    "error" : {
      "root_cause" : [
        {
          "type" : "index_already_exists_exception",
          "reason" : "index [ganesh_index/mg5TckzaR5KZDE-FphTeDg] already exists",
          "index_uuid" : "mg5TckzaR5KZDE-FphTeDg",
          "index" : "ganesh_index"
        }
      ],
      "type" : "index_already_exists_exception",
      "reason" : "index [ganesh_index/mg5TckzaR5KZDE-FphTeDg] already exists",
      "index_uuid" : "mg5TckzaR5KZDE-FphTeDg",
      "index" : "ganesh_index"
    },
    "status" : 400
  }
  </code></pre>
  
  <p>Is there any way to add the normalizer for an existing index (on keyword fields)?</p>