ElasticSearch Update Multi-field Mapping ElasticSearch Update Multi-field Mapping elasticsearch elasticsearch

ElasticSearch Update Multi-field Mapping


Instead of PUT to /my_index do:

POST /my_index/_mapping


You won't be able to change the field type in an already existing index.If you can't recreate your index you can make use of the copy to field to achieve a similar capability.

   PUT /my_index        {          "mappings": {           "my_type": {        "properties": {                   "author":                    {                       "type": "string",                      "copy_to": ["author-name","author-ngram"]                   }                    "author-ngram": {                      "type": "string",                      "indexanalyzer": "ngram_analyzer",                      "search_analyzer": "keyword"                    },                     "author-name" : {                     "type": "string"                    }            }                        }       }     }  }


While I have not tried it in your particular example, it is indeed possible to update field mappings by first closing the index and then applying the mappings.

Example:

POST /my_index/_closePOST /my_index/_mapping{     "my_field:{"new_mapping"}}POST /my_index/_open

I have tested it, by adding a "copy_to" mapping property to mapped field.

Based on https://gist.github.com/nicolashery/6317643.