This is a field in my document:
"date_found": "2018-04-23T22:17:46.6387919+03:00"
My goal is to calculate some value from difference between two datetime fields (e.g. dt1 - dt2)
I running a script to perform such operation:
updateDescriptor.Script(a => a.Inline("ctx._source.lifetime = ctx._source.date_deleted - ctx._source.date_found"));
This operation results with the following error:
"Cannot apply [-] operation to types [java.lang.String] and [java.lang.String]."
How it is advised to perform operations on datetime fields?
dadoonet
(David Pilato)
June 13, 2018, 4:21am
2
I don't remember by heart the syntax but I believe you need first to transform the date object to ms since epoch and then you can do a substraction.
Have a look at what are the available methods for a date type field.
Can I perform such conversion as part of script execution? Where I can find list of available methods you are mentioning?
roshni
(R_C)
June 13, 2018, 5:40am
4
dadoonet
(David Pilato)
June 13, 2018, 6:05am
5
On a mobile now but a quick search and I found
HTH
On mobile now but from quick view it looks like what I need.
Thanks man
system
(system)
Closed
July 11, 2018, 6:26am
7
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.