-(subtraction) of long integer thronging exception in scripted fields in kibana 6.1.2

Hi All,

I am getting an exception as below. Please help me out.

Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"script_exception","reason":"runtime error","script_stack":["return (doc['issues.fields.resolutiondate'].value - doc['issues.fields.created'].value)/1000/60/60/24;"," ^---- HERE"],"script":"if(doc['issues.fields.resolutiondate'].value != 0 && doc['issues.fields.created'].value != 0) return (doc['issues.fields.resolutiondate'].value - doc['issues.fields.created'].value)/1000/60/60/24;","lang":"painless"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"fetch","grouped":true,"failed_shards":[{"shard":0,"index":"jira-db","node":"PyQpy3RDSAu7hMnnEXxGlg","reason":{"type":"script_exception","reason":"runtime error","script_stack":["return (doc['issues.fields.resolutiondate'].value - doc['issues.fields.created'].value)/1000/60/60/24;"," ^---- HERE"],"script":"if(doc['issues.fields.resolutiondate'].value != 0 && doc['issues.fields.created'].value != 0) return (doc['issues.fields.resolutiondate'].value - doc['issues.fields.created'].value)/1000/60/60/24;","lang":"painless","caused_by":{"type":"class_cast_exception","reason":**"Cannot apply [-] operation to types [org.joda.time.DateTime] and [org.joda.time.DateTime]."}}}]},"status":500}**

I think the reason for the above error.

"Cannot apply [-] operation to types [org.joda.time.DateTime] and [org.joda.time.DateTime]."}}}]},"status":500}`

hi @bvnages,

Instead of working with the value property directly, try getting the timestamp explicitly in your script.

doc['@timestamp'].value.getMillis();

There's more info here about using date-functions in Painless here: https://www.elastic.co/guide/en/elasticsearch/painless/5.5/painless-api-reference.html#painless-api-reference-org-joda-time-ReadableDateTime

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.