Groovy script throwing script compilation error


(Andrew ) #1

I have a groovy script I'm trying to use to update the value of a property on a document. I took my old inline script and moved it into a script file in config/scripts called tag_updater.groovy. It contains:

ctx._source.tags = tags

It seems to compile fine generating: compiling script file [/usr/local/elasticsearch-1.4.4/config/scripts/tag_videos.groovy] in my log.

But whenever I try to actually run the script I get:

'ElasticsearchIllegalArgumentException[failed to execute script]; nested: GroovyScriptCompilationException[MultipleCompilationErrorsException[startup failed:\nScript13.groovy: 1: Ambiguous expression could be either a parameterless closure expression or an isolated open code block;\n solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...} @ line 1, column 1.\n {\n ^\n\n1 error\n]];

This is my update script:

'{
"script" : {
"file" : "tag_videos",
"lang" : "groovy",
"params": {
"tags": "'.$this->request->data['tags'].'"
}
}
}'

Edit: It seems I had script.disable_dynamic set to false. When I set it to true, I get:

'ElasticsearchIllegalArgumentException[failed to execute script]; nested: ScriptException[dynamic scripting for [groovy] disabled];

Even though I am not trying to use dynamic scripting. According to docs setting disable_dynamic to false should still allow you to use scripts stored in the config/scripts folder.


(system) #2