2

I am working on ElasticSearch in a scala project. I am using elastic4s as the client. I am trying to add elements to a document, from an iterator one by one.

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
}

The above code does not work yielding the following error:

    [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

The problems is with the script I assume but I could not find any solution. Please help...

6
  • Does adding groovy dependency solve the problem? See here: gist.github.com/hkorte/6efadb547b55976ae466 Commented Mar 6, 2015 at 13:37
  • Nope I have tried it @Opal Commented Mar 6, 2015 at 13:51
  • Does this help (if using ES prior to 1.4) github.com/elasticsearch/elasticsearch/issues/9422 Commented Mar 6, 2015 at 14:11
  • What version of es are you using. Things changed from 1.3.x to 1.4.x what you need to do is make a change to support scripting and potentially groovy but different depending on your version Commented Mar 6, 2015 at 14:34
  • The first link by @Opal actually worked this time thank you all. Commented Mar 6, 2015 at 14:35

1 Answer 1

3

Does adding groovy dependency solve the problem? Please see that: gist.

Sign up to request clarification or add additional context in comments.

1 Comment

To be clear, it's not elastic4s that needs the dep, its any Java-based ES client, of which e4s is one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.