Kibana scripted fields

i am differentiating two date fields and getting the time in milliseconds as output. here is my code
if(!doc['confirmedAt'].empty)
{
return doc['confirmedAt'].value.getMillis() - doc['createdAt'].value.getMillis()
}

i want to divide this by 60000 so that i can get the time in minutes. i am unable to do this. please help me.

Changing above to

return  (doc['confirmedAt'].value.getMillis() - doc['createdAt'].value.getMillis())/60000

should work.

i tried this method @nishant.saini but it is throwing an error saying "Script is invalid".

I've never seen the use of .empty before, are you sure you don't want .size() to determine that the field exists? Here's the walkthrough documentation.

hi @wylie !! thanks for helping out. is there a way to subtract a date field from current time using painless?? I used the below code to do so but it didn't work.
DateTime.now().getMillis() - doc['createdAt'].value

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