# Set operation aggregation

**URL:** <https://discuss.elastic.co/t/set-operation-aggregation/59609>\
**Category:** Elasticsearch\
**Created:** [September 1, 2016, 11:01pm UTC](https://discuss.elastic.co/t/set-operation-aggregation/59609 "2016-09-01T23:01:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaung/32/11165_2.png) [@kaung](https://discuss.elastic.co/u/kaung)\
**Post date:** [September 1, 2016, 11:01pm UTC](https://discuss.elastic.co/t/set-operation-aggregation/59609/1 "2016-09-01T23:01:37Z")

</div>

I am wondering whether elasticsearch has aggregations (other than script aggregation) to support set operations (e.g: union, subtract) like below:  
Input:

> { "users": ["mary", "john"] }  
> { "users": ["john", "alice"] }  
> { "users": ["bob"] }

Aggregated output:

> {"allUsers": ["mary", "john", "alice", "bob"]}

It will be similar to Oracle DB's LISTAGG function but without duplicates ([LISTAGG](http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions089.htm#SQLRF30030))

---

<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:** [July 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/set-operation-aggregation/59609/2 "2017-07-05T22:23:06Z")

</div>

Closed on July 5, 2017, 10:23pm UTC


