Painless Script for Comparing Nested Objects

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.

Hi

Could you show a screenshot how the fields are displayed without any value? Which version of Kibana do you use? If you open the Dev Tools of you Browser are there any error messages in the console tab?

Many thx!
Best,
Matthias

No error messages shown in the console tab. I tried running a query in dev tools and it returned results. We are using Kibana 7.6.2.

Thank you for your reply!