Hi @Rob_wylde
What are your mappings for start_date and last_update? If they're date then you can do
def time_diff = doc['last_update'].value.toInstant().toEpochMilli() -
doc['start_date'].value.toInstant().toEpochMilli()
If you need to parse them because they're keyword, you'll need to parse them using some Datetime methods.
Something like:
ZonedDateTime start = ZonedDateTime.parse(doc['last_update.keyword'].value);
ZonedDateTime last = ZonedDateTime.parse(doc['last_update.keyword'].value);
def time_diff = start.toInstant().toEpochMilli() -
last.toInstant().toEpochMilli();
It's hard to tell, can you provide the exception returned by elasticsearch? It'll look something like:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : []
...
"script": ""
...
"lang" : "painless",
"position" : {
"offset" : 375,
"start" : 331,
"end" : 475
}