Tuesday, November 17, 2015

ElasticsearchIllegalArgumentException[failed to execute script]; nested: ScriptException[scripts of type [inline], operation [update] and lang [groovy] are disabled];

When you use inline scripting as follows:

$ curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '
{
  "script" : "ctx._source.age += 5"
}'

you might get the following error:

{
  "error" : "ElasticsearchIllegalArgumentException[failed to execute script]; nested: ScriptException[scripts of type [inline], operation [update] and lang [groovy] are disabled]; ",
  "status" : 400
}

Because inlining scripting is disabled since 1.4.3, you should enable inline scripting explicitly as follows:

config/elasticsearch.yml

script.inline: on

You can check the result as follows:

$ curl 'localhost:9200/customer/external/1?pretty'

References:
https://www.elastic.co/guide/en/elasticsearch/reference/1.7/_updating_documents.html
https://www.elastic.co/guide/en/elasticsearch/reference/1.7/modules-scripting.html

No comments:

Post a Comment