# Elasticsearch unable to find scripts in the script folder

**URL:** <https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889>\
**Category:** Elasticsearch\
**Created:** [September 24, 2015, 4:56am UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889 "2015-09-24T04:56:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhavy](https://avatars.discourse-cdn.com/v4/letter/v/e480ec/32.png) [@vaibhavy](https://discuss.elastic.co/u/vaibhavy)\
**Post date:** [September 24, 2015, 4:56am UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889/1 "2015-09-24T04:56:20Z")

</div>

Hi,  
I am trying to do scripted metric aggregation by following the example given at:  
[https://www.elastic.co/guide/en/elasticsearch/reference/2.0/search-aggregations-metrics-scripted-metric-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.0/search-aggregations-metrics-scripted-metric-aggregation.html)

The issue I am facing is that elasticsearch is unable to find the script in the scripts folder.  
The various paths are:  
Elasticsearch home: /usr/share/elasticsearch/  
Elasticsearch config: /etc/elasticsearch  
Elasticsearch script folder: /etc/elasticsearch/scripts

I have tried adding the path.config setting as:  
path.config: /etc/elasticsearch/

The .sh file I am using for curl is as follows:

curl -XGET 'localhost:9200/transactions/stock/\_search' -d '{  
"aggs": {  
"profit": {  
"scripted\_metric": {  
"init\_script" : {  
"script\_file": "my\_init\_script",  
"lang": "groovy"  
},  
"map\_script" : {  
"script": "my\_map\_script",  
"lang": "groovy"  
},  
"combine\_script" : {  
"script": "my\_combine\_script",  
"lang": "groovy"  
},  
"params": {  
"field": "amount"  
},  
"reduce\_script" : {  
"script": "my\_reduce\_script",  
"lang": "groovy"  
}  
}  
}  
}  
}'

The error I receive is as follows:  
{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"Unable to find on disk file script [my\_init\_script] using lang [groovy]"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"transactions","node":"Z2yd\_WbOQKGdAjK1J8b\_MA","reason":{"type":"illegal\_argument\_exception","reason":"Unable to find on disk file script [my\_init\_script] using lang [groovy]"}}]},"status":400}

It would be great if anyone could help me figure out what I am doing wrong here?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 24, 2015, 5:23am UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889/2 "2015-09-24T05:23:17Z")

</div>

It should be `/etc/elasticsearch/config/scripts`.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 24, 2015, 5:30am UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889/3 "2015-09-24T05:30:21Z")

</div>

Also check that the filename extension is .groovy

---

<div class="post-metadata">

**Author:** ![PhaedrusTheGreek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phaedrusthegreek/32/4884_2.png) [@PhaedrusTheGreek](https://discuss.elastic.co/u/PhaedrusTheGreek)\
**Post date:** [January 14, 2016, 4:03pm UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889/4 "2016-01-14T16:03:11Z")

</div>

Seems obvious, but this can also happen if your ES conf directory is incorrect.

```auto
root$ ls /etc/elasticsearch
elasticsearch.yml logging.yml	scripts

root$ elasticsearch -Des.default.path.conf=/etc/elasticsearch

```

Also, the permissions on all the config files, including the scripts, must be readable by the ES user.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:24pm UTC](https://discuss.elastic.co/t/elasticsearch-unable-to-find-scripts-in-the-script-folder/29889/5 "2017-07-05T23:24:27Z")

</div>


