# Documentation: Could the example for scripted metric aggregations be rewritten to work with Painless?

**URL:** <https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556>\
**Category:** Elasticsearch\
**Created:** [November 1, 2016, 12:29pm UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556 "2016-11-01T12:29:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fortikeco](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fortikeco](https://discuss.elastic.co/u/fortikeco)\
**Post date:** [November 1, 2016, 12:29pm UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556/1 "2016-11-01T12:29:10Z")

</div>

Hi,  
According to the documentation, I should use groovy for scripted metric agg:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html)

However, as we know, groovy has been deprecated and painless should be used.  
Could you please rewrite the documentation on how to use painless with this same example?

Regards,  
Bjorn

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 1, 2016, 3:16pm UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556/2 "2016-11-01T15:16:43Z")

</div>

Absolutely. I'll add it near the top of my deque. I've been slowly porting all of the docs over to CONSOLE syntax so they get the `SHOW IN CONSOLE` and `COPY AS CURL` links and are automatically tested as part of the build.

---

<div class="post-metadata">

**Author:** ![fortikeco](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fortikeco](https://discuss.elastic.co/u/fortikeco)\
**Post date:** [November 18, 2016, 9:24am UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556/3 "2016-11-18T09:24:23Z")

</div>

Hi,  
I see the documentation has been updated.  
Thank you Nik, great work!  
Regards,  
Bjorn

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [November 18, 2016, 1:12pm UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556/4 "2016-11-18T13:12:29Z")

</div>

Sorry this took so long!

---

<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:05pm UTC](https://discuss.elastic.co/t/documentation-could-the-example-for-scripted-metric-aggregations-be-rewritten-to-work-with-painless/64556/5 "2017-07-05T22:05:38Z")

</div>


