Elasticsearch change field date format

elasticsearch

Solution

You cannot change field mappings after you have indexed documents into Elasticsearch. You can add new fields but you cannot change existing fields.

You could create a new index with the new mappings and then re-index all the data into it. You could then delete the old index and create a new index alias with the old name point to the new index.

There are a few strategies documented for minimizing downtime when changing mappings in the Elasticsearch blog: https://www.elastic.co/blog/changing-mapping-with-zero-downtime

Overall I'd highly suggest using index aliases - they provide a high level of abstraction and flexibility over using index names directly within your application. Perfect for situations like this where you want to make a change to the underlying index: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html

Problem

When i created my index and type a while ago I specified the date format of a field in the mapping as: ``` {"type": "date","format" : "dd/MM/yyyy HH:mm:ss"} ``` Is there a way to change the format of the field knowing that now i have more than 6000 docs indexed in my index ? I want the format to be: ``` {"type": "date","format" : "dd-MM-yyyy HH:mm:ss"} ```

Original source