Hi,
I have this scripted field that calculates the delay of incoming data. I'm made a table viz with unique count on the name field, the split it with a terms bucket for the name and a term for the delay below that. The goal is to show the latest document per name.
The problem I'm having is that the scripted field appears to be returning the calculation for the oldest field, but I want it executed on the newest field.
My data looks something like this
name: John
@original_ingest_time: 18:05
name: John
@original_ingest_time: 18:05
name: John
@original_ingest_time: 18:00
I tried many sorting options but its always returning results for the oldest document.
if (new Date().getTime() - doc['@original_ingest_time'].value.getMillis() >= 86400000) {
return "High"
} else if (new Date().getTime() - doc['@original_ingest_time'].value.getMillis() >= 648000000) {
return "Medium"
} else if (new Date().getTime() - doc['@original_ingest_time'].value.getMillis() >= 3600000) {
return "Low"
} else if (new Date().getTime() - doc['@original_ingest_time'].value.getMillis() >= 0) {
return "Normal"
}