# How to do some aggregation on elastic search with joining

**URL:** <https://discuss.elastic.co/t/how-to-do-some-aggregation-on-elastic-search-with-joining/200676>\
**Category:** Elasticsearch\
**Created:** [September 23, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-to-do-some-aggregation-on-elastic-search-with-joining/200676 "2019-09-23T11:05:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quang\_D\_Tr\_n](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quang_d_tr_n/32/54722_2.png) [@Quang\_D\_Tr\_n](https://discuss.elastic.co/u/Quang_D_Tr_n)\
**Post date:** [September 23, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-to-do-some-aggregation-on-elastic-search-with-joining/200676/1 "2019-09-23T11:05:40Z")

</div>

I have two indices and the result will have a field to join the result sets. After joining, I want to do some count and sum aggregation on the joined result.

Option 1: since join is not supported so using aggregation in each index query would not work either.

Option 2: Get two separate result sets from each index and using java code to join the two lists and then do the aggregation by code.

Could someone please suggest if there is any other better way with Elasticsearch?

---

<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:** [October 21, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-to-do-some-aggregation-on-elastic-search-with-joining/200676/2 "2019-10-21T11:05:42Z")

</div>

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