# Adding script\_fields to transform index using painless scripts

**URL:** <https://discuss.elastic.co/t/adding-script-fields-to-transform-index-using-painless-scripts/240601>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [July 9, 2020, 8:04pm UTC](https://discuss.elastic.co/t/adding-script-fields-to-transform-index-using-painless-scripts/240601 "2020-07-09T20:04:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)\
**Post date:** [July 14, 2020, 1:02pm UTC](https://discuss.elastic.co/t/adding-script-fields-to-transform-index-using-painless-scripts/240601/3 "2020-07-14T13:02:50Z")

</div>

Hi,

we had a bug in our documentation, please check the [docs](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/transform-painless-examples.html#painless-time-features) again for an example.

Instead of `script_fields` use `script` together with an aggregation.

It seems you run into the same issue as the user in this [thread](https://discuss.elastic.co/t/use-painless-script-in-transform-aggregation/240600). Please check his last post for the solution.

---

_[View the full topic](https://discuss.elastic.co/t/adding-script-fields-to-transform-index-using-painless-scripts/240601)._
