Painless script in Kibana to convert timestamp array in Date format

(Karan Shah) #1

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) {
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": [

(Nathan Reese) #2

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

(Karan Shah) #3

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

(system) #4

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