# Can I update a pivot Transform's aggregation script?

**URL:** <https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740>\
**Category:** Elasticsearch\
**Tags:** transforms\
**Created:** [October 14, 2021, 2:38pm UTC](https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740 "2021-10-14T14:38:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsouth](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nsouth](https://discuss.elastic.co/u/nsouth)\
**Post date:** [October 14, 2021, 2:38pm UTC](https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740/1 "2021-10-14T14:38:24Z")

</div>

I have a transform with a scripted metric aggregation. I need to change how some fields are being calculated and I need to drop a few fields. However, the [update API](https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html) doesn't appear to support updating the transform's aggregation. What's the recommendation for updating the aggregation on a transform? Thanks!

---

<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:** [October 15, 2021, 6:08am UTC](https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740/2 "2021-10-15T06:08:41Z")

</div>

The pivot part can't be updated. The technical reason for this is the generation of the document id and therefore the ability to update a bucket. We want to avoid unexpected results and duplicates for the user.

In your case however you can create a transform and reference stored scripts instead of putting the scripts inline. That way you can change the script later.

---

<div class="post-metadata">

**Author:** ![nsouth](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nsouth](https://discuss.elastic.co/u/nsouth)\
**Post date:** [October 15, 2021, 10:34am UTC](https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740/3 "2021-10-15T10:34:38Z")

</div>

Thanks. That makes sense and the stored scripts approach sounds perfect!

---

<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:** [November 12, 2021, 10:35am UTC](https://discuss.elastic.co/t/can-i-update-a-pivot-transforms-aggregation-script/286740/4 "2021-11-12T10:35:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
