Script_file in symlinked subdirectory of config/scripts not executing

Continuing the discussion from Deploying script files to disk across all nodes:

I'm trying to deploy scripts into the config/scripts directory by setting a symlink to a newly deployed release. This effectively puts the scripts into a subdirectory of config/scripts, i.e. config/scripts/myapp/myscript

I notice from looking at elasticsearch .log that the script is found and compiled, but when I try to execute the script in an indexing/update operation I get "ElasticsearchIllegalArgumentException[Unable to find on disk script ..."

What's the issue? Are we not allowed to put scripts in subdirectories, or link them via symlink (even though it appears to find and compile them)? Do I have to add some sort of prefix to the script_file name?

Note: issue filed here: https://github.com/elastic/elasticsearch/issues/12353

I've have not tried loading file scripts from a symlinked directory before, but it looks like its accessible as you mentioned that your are seeing the compile script message in the logs. Could you paste the whole response here as well as the request?

/myapp/release_path/config/elasticsearch/scripts/ includes:
myscript_name.groovy

ln -nfs /myapp/release_path/config/elasticsearch/scripts /etc/elasticsearch/scripts/myapp

Elasticsearch.log:
compiling script file [/etc/elasticsearch/scripts/myapp/myscript_name.groovy]

Request:
curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{
"script" : {
"lang": "groovy",
"script_file": "myscript_name",
"params": {
operation: false,
new_doc: true
}
}
}'

Response:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":"ElasticsearchIllegalArgumentException[failed to execute script]; nested: ElasticsearchIllegalArgumentException[Unable to find on disk script myscript_name]; ","status":400}

Have a look at the documentation here (at the end of the first section just before the "Indexed Scripts" section, but if your script is in scripts/myapp/myscript_name.groovy then you will need to reference your script as myapp_myscript_name.

The name of the script is derived from the hierarchy of directories it exists under, 
and the file name without the lang extension. For example, a script placed under 
config/scripts/group1/group2/test.py will be named group1_group2_test.

That's it. Sorry about that, I looked at that document page several times, but somehow overlooked that paragraph.