I want to find out the difference between two date fields using scripted value. However, the result is always coming as zero. I am using painless as the language (tried with expression also, but still result is zero). I am using the following code in scripted field
doc['time1'].value.getMillis() - doc['time2'].value.getMillis()
Both 'time1' and 'time2' are date fields as shown in Discover tab.