My elasticsearch
script sometimes works ok,and sometimes throw an exception,such as:
{ "error": { "root_cause": [ { "type": "remote_transport_exception", "reason": "[es77][ip:9300] [indices:data/write/update[s]]" } ], "type": "illegal_argument_exception", "reason": "failed to execute script", "caused_by": { "type": "script_exception", "reason": "failed to run inline script [newArray = [];ctx._source.CILastCallResultRemark?.each{ obj->if(obj.id!=item.id){newArray=newArray+obj} }; (ctx._source.CILastCallResultRemark=newArray+item)] using lang [groovy]", "caused_by": { "type": "no_class_def_found_error", "reason": "sun/reflect/MethodAccessorImpl", "caused_by": { "type": "class_not_found_exception", "reason": "sun.reflect.MethodAccessorImpl" } } } }, "status": 400 }
Here is the script:
{ "script": { "inline": "newArray = [];ctx._source.CILastCallResultRemark?.each{ obj->if(obj.id!=item.id){newArray=newArray+obj}};(ctx._source.CILastCallResultRemark=newArray+item)", "params": { "item": { "id": "2", "remart": "x1" } } } }
And here is the es log:
Caused by: ScriptException[failed to run inline script [newArray = [];ctx._source.CILastCallResultRemark?.each{ obj->if(obj.id!=item.id){newArray=newArray+obj}};(ctx._source.CILastCallResultRemark=newArray+item)] using lang [groovy]]; nested: NoClassDefFoundError[sun/reflect/MethodAccessorImpl]; nested: ClassNotFoundException[sun.reflect.MethodAccessorImpl]; at org.elasticsearch.script.groovy.GroovyScriptEngineService$GroovyScript.run(GroovyScriptEngineService.java:318) at org.elasticsearch.action.update.UpdateHelper.executeScript(UpdateHelper.java:251) ... 12 more Caused by: java.lang.NoClassDefFoundError: sun/reflect/MethodAccessorImpl
i see the bug.i will update the es version and try.