1

I'm trying to experiment with using scripts in the config/scripts directory. The Elasticsearch docs here say this:

Save the contents of the script as a file called config/scripts/my_script.groovy on every data node in the cluster:

This seems like it's probably really easy, but I'm afraid I don't understand how exactly to put a groovy file "on every data node in the cluster". Would this normally be done through the command line somehow, or can it be done by manually moving the groovy file (in Finder on OSX for example)? I have a test index, but when I look at the file structure on the nodes I'm confused where to put the groovy file. Help, pretty please.

2 Answers 2

5

You just need to copy the file to each server running elasticsearch. If you're just running elasticsearch on your computer then go to the folder you've installed elasticsearch into and add copy the file into config/scripts in there (you may have to create the folder first). Doesn't matter how the file gets there.

You should see an entry in the logs (or the console if you are running in the foreground) along the lines of

compiling script file [/path/to/elasticsearch/config/scripts/my_script.groovy

This won't show up straightaway - by default elasticsearch checks for new/updated scripts every 60 seconds (you can change this with the watcher.interval setting)

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

2 Comments

Ok, thanks for the quick reply. I had tried that before, so thanks for the reassurance. I was trying to see if it was there by GETting localhost:9200/config/scripts/test.groovy, but it doesn't look like that works.
No, that won't do anything. You should see a line in the logs/terminal window where ES has written saying that it has picked up the script (it only checks every 60s by default)
0

Since file scripts are deprecated (elastic/elasticsearch#24552 & elastic/elasticsearch#24555) this aproach is not going to work anymore.

API it's the only way.

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.