-
Notifications
You must be signed in to change notification settings - Fork 343
Closed
Description
I am trying to execute a groovy-script I have stored on the server, and I get this error, that almost sound like some groovy related library is missing from the image?
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "failed to run file script [sort_by_array_index] using lang [groovy]"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "development_1",
"node": "IxIgjCSmR_SW_5Jj468IOA",
"reason": {
"type": "script_exception",
"reason": "failed to run file script [sort_by_array_index] using lang [groovy]",
"caused_by": {
"type": "bootstrap_method_error",
"reason": "java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/wrappers/Wrapper",
"caused_by": {
"type": "no_class_def_found_error",
"reason": "org/codehaus/groovy/runtime/wrappers/Wrapper",
"caused_by": {
"type": "class_not_found_exception",
"reason": "org.codehaus.groovy.runtime.wrappers.Wrapper"
}
}
}
}
}
]
},
"status": 500
}
Or is there something I need to install? Groovy is built in AFAIK.
Dockerfile
FROM elasticsearch:2.2
RUN plugin install analysis-icu &&\
plugin install lmenezes/elasticsearch-kopf/2.x &&\
plugin install delete-by-query
COPY sort_by_array_index.groovy /usr/share/elasticsearch/config/scripts
sort_by_array_index.groovy
def lowestIdx = ids.size()+1;
def idx = -1;
for (v in doc[fieldName].values) {
idx = ids.indexOf((Integer)v);
if (idx != -1 && lowestIdx > idx) {
lowestIdx = idx;
}
};
return lowestIdx;
And the trigger part in search query:
"sort": [
{
"_script": {
"lang": "groovy",
"type": "number",
"order": "asc",
"script": {
"file": "sort_by_array_index",
"params": {
"fieldName": "list",
"ids": [1,2,3,4,5]
}
}
}
}
]
Metadata
Metadata
Assignees
Labels
No labels