# Combine results of multi field group by

**URL:** <https://discuss.elastic.co/t/combine-results-of-multi-field-group-by/208803>\
**Category:** Elasticsearch\
**Created:** [November 21, 2019, 3:17am UTC](https://discuss.elastic.co/t/combine-results-of-multi-field-group-by/208803 "2019-11-21T03:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chethanBG](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@chethanBG](https://discuss.elastic.co/u/chethanBG)\
**Post date:** [November 21, 2019, 3:17am UTC](https://discuss.elastic.co/t/combine-results-of-multi-field-group-by/208803/1 "2019-11-21T03:17:10Z")

</div>

I have created multiple field aggregation using java api below is the output,

Key : name Value : [{"doc\_count":2,"key":"bhounsley"}]  
Key : id Value : [{"doc\_count":1,"key":1},{"doc\_count":1,"key":4}]

But here I want to get output in this fomat is it possible?

```auto
name id count
=======================
Bhounsley 1 1

Bhounsley 4 1

Raghu 2 1

Basically I want to combine results of multi field aggregation. I am doing this through java api.
```

---

<div class="post-metadata">

**Author:** ![rameshkr1994](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshkr1994/32/59029_2.png) [@rameshkr1994](https://discuss.elastic.co/u/rameshkr1994)\
**Post date:** [November 21, 2019, 1:45pm UTC](https://discuss.elastic.co/t/combine-results-of-multi-field-group-by/208803/2 "2019-11-21T13:45:40Z")

</div>

Hi @chethanBG.

i think you are looking like below output ?

healthrecordkey| sex | firstname  
---------------+---------------+---------------  
10101 |F |Firstname111  
201010 |M |Firstname211  
3202 |F |Firstname3343

OR

| healthrecordkey | sex | firstname |
| --- | --- | --- |
| 120202 | F | Firstname1 |
| 22828 | M | Firstname2 |
| 327272 | F | Firstname3 |

if yes please reply ?  
either leave it?

Thanks  
HadoopHelp

---

<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 19, 2019, 1:45pm UTC](https://discuss.elastic.co/t/combine-results-of-multi-field-group-by/208803/3 "2019-12-19T13:45:40Z")

</div>

Closed on December 19, 2019, 1:45pm UTC

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