# Getting description when aggregating with Elasticsearch

**URL:** <https://discuss.elastic.co/t/getting-description-when-aggregating-with-elasticsearch/77481>\
**Category:** Elasticsearch\
**Created:** [March 6, 2017, 10:53am UTC](https://discuss.elastic.co/t/getting-description-when-aggregating-with-elasticsearch/77481 "2017-03-06T10:53:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fahri\_Cavusoglu](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@Fahri\_Cavusoglu](https://discuss.elastic.co/u/Fahri_Cavusoglu)\
**Post date:** [March 6, 2017, 10:53am UTC](https://discuss.elastic.co/t/getting-description-when-aggregating-with-elasticsearch/77481/1 "2017-03-06T10:53:43Z")

</div>

When we use the aggregation feature on elastic, we get a value of the field we aggregating back but we also want to get the description of that field. We have to use the sector.id as other parts of our api uses it later on. For ex: our data looks like this:

> [{  
> "id":"123"  
> "sectors":[{  
> "id":"sector-1",  
> "name":"Automotive"  
> }]  
> },  
> {  
> "id":"123"  
> "sectors":[{  
> "id":"sector-2",  
> "name":"Biology"  
> }]  
> }]  
> When we aggregate over sectors.id our response looks like:

> "aggregations": {  
> "sector": {  
> "doc\_count\_error\_upper\_bound": 0,  
> "sum\_other\_doc\_count": 0,  
> "buckets": [  
> {  
> "key": "sector-2",  
> "doc\_count": 19672  
> },  
> {  
> "key": "sector-1",  
> "doc\_count": 11699  
> }]  
> }  
> }  
> Is there any way to get sectors.name as well as the key in the results?

---

<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:** [April 3, 2017, 10:53am UTC](https://discuss.elastic.co/t/getting-description-when-aggregating-with-elasticsearch/77481/2 "2017-04-03T10:53:44Z")

</div>

Closed on April 3, 2017, 10:53am UTC

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