# Sorting on the sub-aggregation fields and applying Pagination on the same

**URL:** <https://discuss.elastic.co/t/sorting-on-the-sub-aggregation-fields-and-applying-pagination-on-the-same/328693>\
**Category:** Elasticsearch\
**Created:** [March 28, 2023, 9:31am UTC](https://discuss.elastic.co/t/sorting-on-the-sub-aggregation-fields-and-applying-pagination-on-the-same/328693 "2023-03-28T09:31:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhijeet\_Gosai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhijeet_gosai/32/118414_2.png) [@Abhijeet\_Gosai](https://discuss.elastic.co/u/Abhijeet_Gosai)\
**Post date:** [March 28, 2023, 9:31am UTC](https://discuss.elastic.co/t/sorting-on-the-sub-aggregation-fields-and-applying-pagination-on-the-same/328693/1 "2023-03-28T09:31:00Z")

</div>

I need to sort the aggregation on the basis of sub-aggregation values and also apply pagination on the same .  
I found in documentation that we can do pagination with composite aggregation but can not sort on the basis of sub-aggregation or doc\_count. But if we use normal aggregation we can sort the aggregation on the basis of sub-aggregation but can not apply pagination .  
Can anyone please suggest any way around where I can use both pagination as well as sorting .

---

<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 25, 2023, 9:31am UTC](https://discuss.elastic.co/t/sorting-on-the-sub-aggregation-fields-and-applying-pagination-on-the-same/328693/2 "2023-04-25T09:31:28Z")

</div>

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