# Scroll in top hits aggregation

**URL:** <https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468>\
**Category:** Elasticsearch\
**Created:** [March 8, 2019, 10:09am UTC](https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468 "2019-03-08T10:09:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bard0x](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bard0x](https://discuss.elastic.co/u/bard0x)\
**Post date:** [March 8, 2019, 10:09am UTC](https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468/1 "2019-03-08T10:09:16Z")

</div>

Hi everyone,  
I have a question: it's possible to use the scroll feature in a top hits aggregation?  
I have many documents and I would to load its with a pagination.

Thank's in advance for the replies

---

<div class="post-metadata">

**Author:** ![mjunaidmuzammil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mjunaidmuzammil/32/56910_2.png) [@mjunaidmuzammil](https://discuss.elastic.co/u/mjunaidmuzammil)\
**Post date:** [March 8, 2019, 11:02am UTC](https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468/2 "2019-03-08T11:02:10Z")

</div>

> [@bard0x](#):
>
> aggregation

You may not be able to use scroll, but you can paginate the terms aggregations by using the `num_partitions` option. If you are using the `top_hits` aggregation along with the `terms` aggregation, you can benefit from this feature.

> **[Terms aggregation | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html)**

For other aggregations, I haven't found any way to paginate up till now. Hope this helps.

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [March 8, 2019, 12:10pm UTC](https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468/3 "2019-03-08T12:10:07Z")

</div>

> [@bard0x](#):
>
> it's possible to use the scroll feature in a top hits aggregation?

Perhaps [Composite Aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html) is what you're looking for? It allows you to:

> paginate **all** buckets from a multi-level aggregation efficiently. This aggregation provides a way to stream **all** buckets of a specific aggregation similarly to what [scroll](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) does for documents.

---

<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 5, 2019, 12:10pm UTC](https://discuss.elastic.co/t/scroll-in-top-hits-aggregation/171468/4 "2019-04-05T12:10:15Z")

</div>

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