# Perform aggregation on a modified term

**URL:** <https://discuss.elastic.co/t/perform-aggregation-on-a-modified-term/330141>\
**Category:** Elasticsearch\
**Created:** [April 17, 2023, 2:11pm UTC](https://discuss.elastic.co/t/perform-aggregation-on-a-modified-term/330141 "2023-04-17T14:11:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manropinxu](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@manropinxu](https://discuss.elastic.co/u/manropinxu)\
**Post date:** [April 17, 2023, 2:11pm UTC](https://discuss.elastic.co/t/perform-aggregation-on-a-modified-term/330141/1 "2023-04-17T14:11:29Z")

</div>

I'd like to perform an aggregation grouping by a modified version of a_message_ field.

I have lots of messages like

`invalid x with uuid=1e659cfc-a375-4a8a-88f5-467419fdf87d`  
`invalid x with uuid=49c4742e-0368-49a2-aab4-7f59b2e89ec8`

I want them to end up in the same aggregation bucket by replacing the uuid with ''  
the idea would be something in the direction of:

```auto
{
            "size": 0,
            "query": {
            },
            "aggs": {
                "my_aggregation": {
                    "terms": {
                        "size": 1000,
                        "field": "message.keyword.replace(uuid_regex,'<UUID>')"
                    }
                }
            }
        }

```

---

<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:** [May 15, 2023, 2:11pm UTC](https://discuss.elastic.co/t/perform-aggregation-on-a-modified-term/330141/2 "2023-05-15T14:11:30Z")

</div>

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