0

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?

5
  • have you enabled dynamic scripting in your configuration? Commented Oct 6, 2016 at 9:03
  • 1
    As far I've been able to figure out, script files are enabled by default. Dynamic scripting is refering to inline scripts, isn't it? Commented Oct 6, 2016 at 9:12
  • dynamic scripting can be enabled for inline, file and indexed scripts. You probably need to enable file scripts with script.file: true Commented Oct 6, 2016 at 9:21
  • 1
    script.file is set to true by default. See elastic.co/guide/en/elasticsearch/reference/current/… Commented Oct 6, 2016 at 9:23
  • 1
    @OrWeinberger just making sure this wasn't overlooked Commented Oct 6, 2016 at 9:50

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.