How to use SQL version of STUFF and groupby in elastic search

For example assume mapping is following :

ID User Color
1 one blue
2 one black
3 two orange
4 two yellow

Needed Result is.

ID User Color
1 one blue, black
2 two orange, yellow

In case of SQL this can be done by GroupBy and STUFF.
How this can be done in ES.

If you are grouping by User then just do a terms aggregation on that - https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-bucket-terms-aggregation.html

This will just give count. How to merge column values.

You'll probably need to do that externally once you have the buckets.

Thanks for suggestion.