# Enable groovy scripting in Elasticsearch

**URL:** <https://discuss.elastic.co/t/enable-groovy-scripting-in-elasticsearch/59420>\
**Category:** Elasticsearch\
**Created:** [August 31, 2016, 11:54am UTC](https://discuss.elastic.co/t/enable-groovy-scripting-in-elasticsearch/59420 "2016-08-31T11:54:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankureck](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@ankureck](https://discuss.elastic.co/u/ankureck)\
**Post date:** [August 31, 2016, 11:54am UTC](https://discuss.elastic.co/t/enable-groovy-scripting-in-elasticsearch/59420/1 "2016-08-31T11:54:23Z")

</div>

I am trying to enable groovy scripts on my elastic search.

I have updated my elasticsearch.yml file with following lines

script.inline: true  
script.groovy.sandbox.enabled: true  
script.inline: on  
script.indexed: on  
script.search: on  
script.engine.groovy.inline.aggs: on  
script.engine.groovy.inline.search: on  
I then craeted a script using this

curl -XPOST localhost:9200/\_scripts/groovy/indexedCalculateScore -d '{  
"script": "log(\_score \* 2) + my\_modifier"  
}'  
and tried to access it using :

curl -XPOST localhost:9200/\_search -d '{  
"query": {  
"function\_score": {  
"query": {  
"match": {  
"body": "foo"  
}  
},  
"functions": [  
{  
"script\_score": {  
"script": {  
"id": "indexedCalculateScore",  
"lang" : "groovy",  
"params": {  
"my\_modifier": 8  
}  
}  
}  
}  
]  
}  
}  
}'  
I am getting following exception

{"error":{"root\_cause":[{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"},{"type":"script\_exception","reason":"scripts of type [indexed], operation [search] and lang [groovy] are disabled"}

It seems from the logs that groovy is not enabled.

Can anybody help out with configurations.

Also please help as how can i write dynamic in elasticsearch using groovy?

I am using following link to enable groovy scripting in elasticsearch

[https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html).

---

<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, 10:23pm UTC](https://discuss.elastic.co/t/enable-groovy-scripting-in-elasticsearch/59420/2 "2017-07-05T22:23:36Z")

</div>


