Jordi
Jordi

Reputation: 23187

ElasticSearch Unable to find on disk file script

I'm trying to perform a groovy script using Java API:

AggregationBuilders
    .terms(this.getName())
    .field(this.getName())
    .script(
        new Script(
            "year",
            ScriptType.FILE,
            "groovy",
            ImmutableMap.of("name", this.getName())
        )
    );

I'm running an elasticsearch instance using a custom made docker image. This is the DockerFile:

FROM elasticsearch:2.4
MAINTAINER me

COPY ./year.groovy /etc/elasticsearch/scripts

As you can see I'm providing my script file COPYing the file in /etc/elaticsearch/scripts.

I've checked out on /etc/elasticsearch/scripts:

#docker exec -it es ls /etc/elasticsearch/scripts -l
-rw-r--r--. 1 root root 70 Oct  6 07:24 year.groovy

However, when the java code is reached, it's telling me:

Unable to find on disk file script [year] using lang [groovy];

Any ideas?

Upvotes: 0

Views: 724

Answers (1)

Or Weinberger
Or Weinberger

Reputation: 7472

The Elasticsearch docker image uses different default paths, looking at the relevant Dockerfile I can see that it has a reference to /usr/share/elasticsearch/config/scripts, try placing your groovy script there and see if that works.

Upvotes: 2

Related Questions