Painless script in Kibana to convert timestamp array in Date format

Hi, I have an array of of Epoch time in timestamp field. I want to use painless script to convert this array field in Date field which can be used by Kibana.

Following is my painless script

LocalDateTime date;
for (int i = 0; i < doc['timestamp'].length; ++i) {
return
date = LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['timestamp'][i].value), ZoneId.of('Z')).getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault())
}

My Timestamp field looks like this
"timestamp": [
"1516402800000",
"1516424400000",
"1516446000000",
]

What is the mapping for the field? Why don't you store them as Dates in Elasticsearch?

https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html

I have all the dates in an array and Date filter will not convert an array into Date.

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