Elasticsearch 2.4.4 - compilation failure with groovy dynamic scripting which works fine in 2.1.1


(Parvathy) #1

Hi,
I am using dynamic scripting with groovy in Elasticsearch 2.4.4. The script gives a compilation error, whereas the same script was working fine in Elasticsearch 2.1.1. I have verified the script complies fine in a groovy console.

The script works if the cast is removed but I would like to understand if there is any restriction in using the LinkedHashMap in groovy in 2.4.4, as I am aware that from 5.0 some restriction is made for security.

Error:
caused_by":{"type":"script_exception","reason":"Error compiling script b065d53a6f4fa2969360ce7776fc0abfa1cd1f21","caused_by":{"type":"multiple_compilation_errors_exception","reason":"startup failed:\nb065d53a6f4fa2969360ce7776fc0abfa1cd1f21: 28: unable to resolve class LinkedHashMap

_Code Snippet:

if (!found) {
target.paths.add((LinkedHashMap)source);
}_

Any help in this regard is greatly appreciated.
Thanks!
Parvathy.


(Ryan Ernst) #2

In 2.2.0, groovy was moved into an elasticsearch module (essentially a plugin that is installed automatically). Part of that was moving scripting security into each plugin, so each script engine handles its own whitelist of available classes. See https://www.elastic.co/guide/en/elasticsearch/reference/2.4/modules-scripting-security.html. Also, you might consider just casting to Map, as that should be available.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.