elasticsearch:script sometimes works ok sometimes throw an exception

匿名 (未验证) 提交于 2019-12-03 09:13:36

问题:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!