Thank you Patrick for responding..
Could you please give one Eg for casting?
Here is the error with String . format
{
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['TimeStamp'].value.getMonth() + String.format("%d", doc['TimeStamp'].value.getYear())",
" ^---- HERE"
],
"script": "doc['TimeStamp'].value.getMonth() + String.format("%d", doc['TimeStamp'].value.getYear())",
"lang": "painless",
"position": {
"offset": 78,
"start": 0,
"end": 89
}
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "iq",
"node": "uJDR1PCXTdSJpz--zeIPBg",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"doc['TimeStamp'].value.getMonth() + String.format("%d", doc['TimeStamp'].value.getYear())",
" ^---- HERE"
],
"script": "doc['TimeStamp'].value.getMonth() + String.format("%d", doc['TimeStamp'].value.getYear())",
"lang": "painless",
"position": {
"offset": 78,
"start": 0,
"end": 89
},
"caused_by": {
"type": "wrong_method_type_exception",
"reason": "cannot convert MethodHandle(JodaCompatibleZonedDateTime)int to (Object)Object"
}
}
}
]
}