# Aggregation query to fetch item list

**URL:** <https://discuss.elastic.co/t/aggregation-query-to-fetch-item-list/41180>\
**Category:** Elasticsearch\
**Created:** [February 8, 2016, 12:54pm UTC](https://discuss.elastic.co/t/aggregation-query-to-fetch-item-list/41180 "2016-02-08T12:54:05Z")\
**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:** [February 8, 2016, 12:54pm UTC](https://discuss.elastic.co/t/aggregation-query-to-fetch-item-list/41180/1 "2016-02-08T12:54:05Z")

</div>

Hi All,

We have an index es\_item. The document count of es\_item is 205,059,966 with nearly 850 GB primary size. Index **es\_item** contains standards items along with cross codes (For example:- Each standard\_item will have more than one cross codes). The cross codes are nothing but sub document of each item.  
For our analyzing purpose we would like to know,  
How to get standard item's of having more than 10,000 cross codes?

Below query will fetch total cross code count of an item (based of item id). My doubt is if XCD is greater than 10,000 then it should fetch all items having matched the criteria. Please guide us

**Sample Query:-**  
GET es\_item/item/\_search  
{  
"query": {  
"filtered": {  
"filter": {  
"term": {  
"\_id": "4356760"  
}  
}  
}  
},  
"fields": [  
"FIELD"  
],  
"script\_fields": {  
"FIELD": {  
"script": "return \_source.XCD.size()"  
}  
}  
}

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, 11:18pm UTC](https://discuss.elastic.co/t/aggregation-query-to-fetch-item-list/41180/2 "2017-07-05T23:18:14Z")

</div>

Closed on July 5, 2017, 11:18pm UTC


