# Return many values from Painless script to aggregation

**URL:** <https://discuss.elastic.co/t/return-many-values-from-painless-script-to-aggregation/108150>\
**Category:** Elasticsearch\
**Created:** [November 17, 2017, 2:55pm UTC](https://discuss.elastic.co/t/return-many-values-from-painless-script-to-aggregation/108150 "2017-11-17T14:55:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![merito](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/merito/32/24309_2.png) [@merito](https://discuss.elastic.co/u/merito)\
**Post date:** [November 17, 2017, 2:55pm UTC](https://discuss.elastic.co/t/return-many-values-from-painless-script-to-aggregation/108150/1 "2017-11-17T14:55:16Z")

</div>

Hi,

is it possible to get more than one value from script in e.g., terms aggregation from one document? I would like to have an aggregation of values of two fields using the script. I know I can use `copy_to` in mapping or other feature, but values I want to aggregate need manipulations. Can I return the List or something else?

Regards

---

<div class="post-metadata">

**Author:** ![merito](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/merito/32/24309_2.png) [@merito](https://discuss.elastic.co/u/merito)\
**Post date:** [November 17, 2017, 3:05pm UTC](https://discuss.elastic.co/t/return-many-values-from-painless-script-to-aggregation/108150/2 "2017-11-17T15:05:19Z")

</div>

I've tried with ArrayList and it works 😉

---

<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 15, 2017, 3:05pm UTC](https://discuss.elastic.co/t/return-many-values-from-painless-script-to-aggregation/108150/3 "2017-12-15T15:05:24Z")

</div>

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