gpt4 book ai didi

scala - Elasticsearch脚本将元素添加到数组中

转载 作者:行者123 更新时间:2023-12-02 22:20:24 25 4
gpt4 key购买 nike

我正在一个scala项目中从事ElasticSearch的工作。我正在使用elastic4s作为客户端。我试图将元素从一个迭代器一个接一个地添加到文档中。

while (iterator.hasNext) {
counter +=1
client.execute {
update id reportID in "reports/report" script "ctx._source.elasticData += output" params Map("output" -> iterator.next().toStringifiedJson)
}.await
}

上面的代码不起作用,产生以下错误:
    [ERROR] [03/06/2015 14:44:23.515] [SparkActorSystem-akka.actor.default-dispatcher-5] [akka://SparkActorSystem/user/spark-actor] failed to execute script
org.elasticsearch.ElasticsearchIllegalArgumentException: failed to execute script
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:189)
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.ElasticsearchIllegalArgumentException: script_lang not supported [groovy]
at org.elasticsearch.script.ScriptService.dynamicScriptEnabled(ScriptService.java:521)
at org.elasticsearch.script.ScriptService.verifyDynamicScripting(ScriptService.java:398)
[ERROR] [03/06/2015 14:44:23.515] [SparkActorSystem-akka.actor.default-dispatcher-5] [akka://SparkActorSystem/user/spark-actor] failed to execute script
org.elasticsearch.ElasticsearchIllegalArgumentException: failed to execute script
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:189)
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.ElasticsearchIllegalArgumentException: script_lang not supported [groovy]
at org.elasticsearch.script.ScriptService.dynamicScriptEnabled(ScriptService.java:521)
at org.elasticsearch.script.ScriptService.verifyDynamicScripting(ScriptService.java:398)
at org.elasticsearch.script.ScriptService.compile(ScriptService.java:363)
at org.elasticsearch.script.ScriptService.executable(ScriptService.java:503)
at org.elasticsearch.action.update.UpdateHelper.prepare(UpdateHelper.java:183)
... 6 moreat org.elasticsearch.script.ScriptService.compile(ScriptService.java:363)
at org.elasticsearch.script.ScriptService.executable(ScriptService.java:503)
at org.elasticsearch.
action.update.UpdateHelper.prepare(UpdateHelper.java:183)
... 6 more

问题出在我假定的脚本上,但找不到任何解决方案。请帮忙...

最佳答案

添加groovy依赖性是否可以解决问题?请注意:gist

关于scala - Elasticsearch脚本将元素添加到数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28899320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com