# ES aggregation Query clarification

**URL:** <https://discuss.elastic.co/t/es-aggregation-query-clarification/54394>\
**Category:** Elasticsearch\
**Created:** [June 30, 2016, 11:20am UTC](https://discuss.elastic.co/t/es-aggregation-query-clarification/54394 "2016-06-30T11:20:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.ganeshbabu](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@r.ganeshbabu](https://discuss.elastic.co/u/r.ganeshbabu)\
**Post date:** [June 30, 2016, 11:20am UTC](https://discuss.elastic.co/t/es-aggregation-query-clarification/54394/1 "2016-06-30T11:20:02Z")

</div>

Hi All,

I am trying to form an aggregation query to get the top document for an item, Since we have indexed a data as like this, A single item has been partitioned into multiple documents as like below,

Item:- 012312  
Partitioned the item into multiple documents 012312\_1, 012312\_2 etc..

Below is the aggregation query,

GET /es\_item/item/\_search  
{  
"size": 0,  
"aggs": {  
"item\_types": {  
"terms": {  
"field": "ITEM\_ID"  
}  
}  
}  
}

The above query fetches the top 10 items from the overall indexed data and values are showing in desc order,

I want to pass a single item\_id in the aggregation query and get the top document in desc order.

Please help us to get this.

Thanks,  
Ganeshbabu R

---

<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:39pm UTC](https://discuss.elastic.co/t/es-aggregation-query-clarification/54394/2 "2017-07-05T22:39:14Z")

</div>

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


