# Stats aggregation: value script broken due to Groovy scripting disabled

**URL:** <https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533>\
**Category:** Elasticsearch\
**Created:** [March 5, 2015, 5:32pm UTC](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533 "2015-03-05T17:32:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BradVido](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradvido/32/741_2.png) [@BradVido](https://discuss.elastic.co/u/BradVido)\
**Post date:** [March 5, 2015, 5:32pm UTC](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533/1 "2015-03-05T17:32:28Z")

</div>

I understand that Groovy dynamic scripting has been disabled by default in  
1.4.4 and I should either use a different language or put the script in the  
config/scripts directory.

However, when calling a script for the value of a Stats aggregation  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html#\_script\_5](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html#_script_5),  
I cannot figure out how to specify the script\_file parameter. I'm using the  
Java API and the StatsBuilder class has only 1 method for the script, which  
accepts a sting:  
StatsBuilder.stats(String script)

If I specify the script string, I get (as expected):  
ScriptException[dynamic scripting for [groovy] disabled]

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [March 6, 2015, 9:07am UTC](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533/2 "2015-03-06T09:07:48Z")

</div>

Hi Brad,

Giving the name of the file as a script (without extension) should work.  
However I agree this is confusing and opened  
[Scripting: Java API does not match the REST layer · Issue #10011 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/10011).

On Thu, Mar 5, 2015 at 6:32 PM, BradVido [bradyvidovic@gmail.com](mailto:bradyvidovic@gmail.com) wrote:

> I understand that Groovy dynamic scripting has been disabled by default in  
> 1.4.4 and I should either use a different language or put the script in the  
> config/scripts directory.
> 
> However, when calling a script for the value of a Stats aggregation  
> [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html#\_script\_5](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html#_script_5),  
> I cannot figure out how to specify the script\_file parameter. I'm using the  
> Java API and the StatsBuilder class has only 1 method for the script,  
> which accepts a sting:  
> StatsBuilder.stats(String script)
> 
> If I specify the script string, I get (as expected):  
> ScriptException[dynamic scripting for [groovy] disabled]
> 
> Thanks!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/83258db0-c815-4508-8adb-d5be4d7ee0a5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6uSqXRURWPStKpfdo%3DJ4JV9F4s-2Dw0UKSuR7XOpcUkg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6uSqXRURWPStKpfdo%3DJ4JV9F4s-2Dw0UKSuR7XOpcUkg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![BradVido](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bradvido/32/741_2.png) [@BradVido](https://discuss.elastic.co/u/BradVido)\
**Post date:** [March 6, 2015, 2:11pm UTC](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533/3 "2015-03-06T14:11:59Z")

</div>

Great. That worked and thanks for opening the github issue! I see that  
others agree this needs to be fixed.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6d8a438c-b1d4-4901-88b6-7d82d09a887c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6d8a438c-b1d4-4901-88b6-7d82d09a887c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:28am UTC](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533/4 "2017-07-06T00:28:05Z")

</div>


