Changing field format into proper date format that has date as TEXT

hi, I currently have a field that is in this text format ( some field has "2019/03/25 00:00:00.000" and some docs in same field has "20190619"). I changed the mapping for the field as DATE (yyyy/MM/dd HH:mm:ss.SSSZZ), but the reindexing stops in halfway. It says some of the date length is small or something. Help me out here. what should be my correct mapping for this date?

Can you please let me see the error? Have you considered using a pipeline to transform the date field?

I didnot saved the error unfortunately. But, I tried different approach. since some of my docs were in yyyyMMdd, I created mapping like this while indexing and it worked. It reindexed everything. Now, I can do aggregation on the dates also. But, now I want to know how to change those yyyyMMdd format into the regular format yyyy/MM/dd. Any idea?:
"field" : {
"type" : "date",
"format" : "yyyy/MM/dd HH:mm:ss.SSSZZ||yyyy/MM/dd HH:mm:ss.SSS||yyyy/MM/dd||yyyyMMdd"

If you are using Kibana, you can change the format of the displayed data in advanced settings. But if not, you cannot change the format defined in the mapping once created.

What you should do is to manage to recieve and recognize any date format when indexing, then in your mapping define just the format you want to see in your index. As you are reindexing i recomend you using pipelines to recognize those date formats Elasticsearch is not seeing. And if you can index the data again like using logstash, use filters to show to elasticsearch those fields that are dates.

I am using kibana to reindex. Are you saying with pipeline, i will be able to change certain date format from source to destination while reindexing?

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