I'm trying to add field for the data view in Kibana UI and I'm (trying) using painless script to do that (set value).
The document in the index has "start_time" and "close_time" fields (date format) and I'm trying to calculate the duration between start and close (close - start). When I use the script inside agg or query it works fine ie the script source is eg:
if (doc['close_time'].size() != 0 && doc['start_time'].size() != 0) {doc['close_time'].value.getMillis() - doc['start_time'].value.getMillis()}
What I'm experiencing in the Define script on Kibana UI is that any field that is even offered by UI as existing field name in the document says always that
"A document doesn't have a value for a field! Use doc[].size()==0 to check if a document is missing a field!"
I tried to even run some sample scripts and examples I have found and the authors do not seem to have any issue when referring to eg "ZoneDateTime start = doc['some_datetime_field'].value" and then emitting the start value however if I use those examples and simply replace datetime field with my existing document field I got the error above.
So whats going on in my case? Why the UI fails to "see" that document field? Is it some bug or I got it completely wrong and Kibana UI is using different formating?
Btw. I'm on 8.15.2 if that matters...