# Concat String results in aggregation

**URL:** <https://discuss.elastic.co/t/concat-string-results-in-aggregation/257385>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [December 2, 2020, 4:04pm UTC](https://discuss.elastic.co/t/concat-string-results-in-aggregation/257385 "2020-12-02T16:04:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoandy\_Perez\_Villazo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yoandy_perez_villazo/32/63153_2.png) [@Yoandy\_Perez\_Villazo](https://discuss.elastic.co/u/Yoandy_Perez_Villazo)\
**Post date:** [December 2, 2020, 4:04pm UTC](https://discuss.elastic.co/t/concat-string-results-in-aggregation/257385/1 "2020-12-02T16:04:02Z")

</div>

He, I'm trying build a query with aggregation included, the aggregation define a sum of numeric values and i need further retrieve the \_ids list of items concatenated ... this is part of my aggregation ...

```auto
     "aggs": {
            "group_by_balance_currency": {
                "terms": {
                    "field": "balance_currency.keyword",
                    "size": 500000,
                    "order": {
                        "_key": "asc"
                    }
                },
                "aggs": {
                    "sum_of_amount": {
                        "sum": {
                            "field": "balance_amount"
                        }
                    }
                }
            },
            // Here I need concat _id of items
           
         }
      }

```

The key of problem is how concat de \_id separated by comma in the second part of aggregation, just in comment place.

---

<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:** [December 30, 2020, 4:04pm UTC](https://discuss.elastic.co/t/concat-string-results-in-aggregation/257385/2 "2020-12-30T16:04:10Z")

</div>

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