Elasticsearch 6.2 - how to format date (epoch) field in yyyymm string in painless inline scripting


(pungent) #1

In Elasticsearch 6.2, I have an index where there are two timestamp fields as follows:

"start_ts":  { "type": "date", "format": "epoch_second"  },                       
"end_ts":    { "type": "date", "format": "epoch_second"  }  

In my painless inline script, for some calculation, I want to convert them (doc["start_ts"] and doc["end_ts"]) to this string format (yyyymm). Any idea how can it be done? I could not find any documentation for formatting in ES official documentation.


How to format a date as a string in Painless
(system) #2

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