Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch change field date format

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"}
like image 240
Rachid O Avatar asked Jul 12 '14 16:07

Rachid O


People also ask

What is default date format in Elasticsearch?

SSSZ or yyyy-MM-dd .

How do I change the date format in Kibana?

Advanced Settings control the behavior of Kibana. For example, you can change the format used to display dates, specify the default data view, and set the precision for displayed decimal values. Open the main menu, then click Stack Management > Advanced Settings. Scroll or search for the setting.

How do you format a date?

Press CTRL+1. In the Format Cells box, click the Number tab. In the Category list, click Date, and then choose a date format you want in Type.


1 Answers

You can update format mapping on an existing date field with the PUT mapping API:

PUT twitter/_mapping/user 
{
  "properties": {
    "myDate": {
      "format": "dd-MM-yyyy HH:mm:ss"
    }
  }
}

format is one of the few mappings that can be updated on existing fields without losing data

https://www.elastic.co/guide/en/elasticsearch/reference/2.0/mapping-date-format.html

like image 182
redDevil Avatar answered Sep 23 '22 06:09

redDevil