We were using the below groovy script in 1.7.3 and now we are upgrading to 5.5.0 and the below groovy script is throwing "unexpected token ['groovy'] was expecting one of [{, ';'}]." message. Can you please help us in resolving it.
POST xxx_index/yyyy_type/_bulk
{"update":{"_id":"as23f4", "_retry_on_conflict" : 25}}
{
"script": "import groovy.json.;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx._source.ADC.addAll(object)",
"params": {
"newValues": "[{"ADC_ID":1234,"ADC_CODE":"00001234","ADC_PRC":null}]"
}
}
{"update":{"_id":"av45hj78", "_retry_on_conflict" : 25}}
{
"script": "import groovy.json.;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx._source.ADC.addAll(object)",
"params": {
"newValues": "[{"ADC_ID":2345,"ADC_CODE":"00002345","ADC_PRC":45.8}]"
}
}
ERROR:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[dayrhebfmd001_DEV_550_DATA][10.7.147.21:9264][indices:data/write/update[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"import groovy.json.;def jsonSlu ...",
" ^---- HERE"
],
"script": "import groovy.json.;def jsonSlurper = new JsonSlurper();def object = jsonSlurper.parseText(newValues);ctx._source.XCD.addAll(object)",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected token ['groovy'] was expecting one of [{, ';'}]."
}
}
},
"status": 400
}