Hi,
We have a use case where we need to compare two dates that are inside a nested field and show the result to another field. Generally, if time1 > time2, it would show 'Incorrect', and 'Correct' otherwise. Here is my working script:
if (params._source['a.time1'].value.getMillis() >=
params._source['b.time2'].value.getMillis()) {
return 'Incorrect'
}
else {
return 'Correct'
}
Since it's in a nested field, I used params._source instead of doc. When I save and run the script, the other fields from the index are somewhat removed from the Discover page. Only the scripted field is shown without any value. I've modified the script to cater to non-nested objects and the script worked properly. Is there a way to call nested objects and use them in painless? Thank you.