将元素添加到数组中的 Elasticsearch 脚本
Elasticsearch Scripts to add element into an array
我正在 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.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.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。我使用 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.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.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.