# Rename Terms Aggregation Buckets

**URL:** https://discuss.elastic.co/t/rename-terms-aggregation-buckets/253432
**Category:** Kibana
**Created:** [October 27, 2020, 11:55am UTC](https://discuss.elastic.co/t/rename-terms-aggregation-buckets/253432 "2020-10-27T11:55:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Smirra](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Smirra](https://discuss.elastic.co/u/Smirra)
#### Post date: [October 27, 2020, 11:55am UTC](https://discuss.elastic.co/t/rename-terms-aggregation-buckets/253432/1 "2020-10-27T11:55:22Z")

</div>

I would like to apply a common renaming rule to the aggregated terms buckets (such as using regex) that removes part of the names shown in red below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/f/afada80dba580a5f798c759ec2d3d75942fb48fa.png)

The dream would be to add a regex somewhere (doing something like /(/Accounts\*).\*$/), but that does not seem to be possible. I looked into adding some custom query to the advanced "JSON input" etc and googled around alot. The best thing I have yet found is to add a "Scripted field" but it has not been used by us before, so it would be awesome to just find another way to do it directly within the dashboard or modifying its source. Any ideas?

Thanks!  
Lukas

---

<div class="post-metadata">

### Author: ![myasonik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myasonik/32/62369_2.png) [@myasonik](https://discuss.elastic.co/u/myasonik)
#### Post date: [October 29, 2020, 4:47pm UTC](https://discuss.elastic.co/t/rename-terms-aggregation-buckets/253432/2 "2020-10-29T16:47:27Z")

</div>

A scripted field is really the answer here.

Some links in case you haven't seen them: [Scripted fields technical docs](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) and a [blog post on scripted fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields) (a little old now but still basically accurate).

---

<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 26, 2020, 4:47pm UTC](https://discuss.elastic.co/t/rename-terms-aggregation-buckets/253432/3 "2020-11-26T16:47:52Z")

</div>

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