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.

chevin99
  • 4,946
  • 7
  • 24
  • 32

2 Answers2

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)

Frederick Cheung
  • 83,189
  • 8
  • 152
  • 174
  • 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 http://localhost:9200/config/scripts/test.groovy, but it doesn't look like that works. – chevin99 Apr 01 '15 at 21:25
  • 1
    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) – Frederick Cheung Apr 02 '15 at 06:00
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.

icalvete
  • 987
  • 2
  • 16
  • 50