# How to efficiently implement pagination along with aggregation?

**URL:** <https://discuss.elastic.co/t/how-to-efficiently-implement-pagination-along-with-aggregation/369281>\
**Category:** Elastic Search\
**Created:** [October 23, 2024, 11:54am UTC](https://discuss.elastic.co/t/how-to-efficiently-implement-pagination-along-with-aggregation/369281 "2024-10-23T11:54:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhi\_desigan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhi_desigan/32/138619_2.png) [@sudhi\_desigan](https://discuss.elastic.co/u/sudhi_desigan)\
**Post date:** [October 23, 2024, 11:54am UTC](https://discuss.elastic.co/t/how-to-efficiently-implement-pagination-along-with-aggregation/369281/1 "2024-10-23T11:54:33Z")

</div>

If I prefer composite aggregation, then for say Nth page, I need to query (n-1) times to get after\_key value which is inefficient. Can someone please suggest efficient way to achieve the same?

---

<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:** [November 20, 2024, 11:55am UTC](https://discuss.elastic.co/t/how-to-efficiently-implement-pagination-along-with-aggregation/369281/2 "2024-11-20T11:55:26Z")

</div>

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