【问题标题】:Error on update:org.elasticsearch.ElasticsearchIllegalArgumentException: failed to execute script更新错误:org.elasticsearch.ElasticsearchIllegalArgumentException:执行脚本失败
【发布时间】:2015-10-15 10:33:08
【问题描述】:

我有以下文件{

 "_index" : "Testdb",
  "_type" : "directUser",
  "_id" : "123",
  "_version" : 8,
  "found" : true,
  "_source":{"uuid":"123",
"Email":"mail@example.com"
,"SecondryEmail":"mail2@example.com"
,"FirstName":"personFirstNmae"
,"LastName":"personLastName"
,"UserStatus":"INACTIVE"
,"Password":"pwd"
}}

我想更新LastName 字段的值 这是我的代码

var lastname="lname"

var params:java.util.Map[String,Object] = Maps.newHashMap();
params.put("lastname", value);


val response = client.prepareUpdate("testdb", "directUser", directUserObj.getUuid)
.setScript("ctx._source.LastName = lastname",ScriptService.ScriptType.INLINE)
.setScriptParams(params)
.execute().actionGet();

但此代码引发以下异常

org.elasticsearch.ElasticsearchIllegalArgumentException: failed to execute script
    at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:202)
    at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:176)
    at org.elasticsearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:170)
    at org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction$1.run(TransportInstanceSingleOperationAction.java:187)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.script.ScriptException: scripts of type [inline], operation [update] and lang [groovy] are disabled
    at org.elasticsearch.script.ScriptService.compile(ScriptService.java:285)
    at org.elasticsearch.script.ScriptService.executable(ScriptService.java:457)
    at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:196)
    ... 6 more

请指导我我出了什么问题,我使用的是 elasticsearch 1.6 版

【问题讨论】:

    标签: java scala elasticsearch updates scala-2.11


    【解决方案1】:

    这是相关的错误信息:

    Caused by: org.elasticsearch.script.ScriptException: scripts of type [inline], operation [update] and lang [groovy] are disabled
    

    这意味着你需要添加这个:

    script.engine.groovy.inline.update: on
    

    elasticsearch.yml文件并重启节点。

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 2021-04-24
      • 2011-06-28
      • 2021-05-18
      • 2021-09-19
      • 2020-11-24
      • 2020-08-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多