# Slice the aggregation

**URL:** <https://discuss.elastic.co/t/slice-the-aggregation/116160>\
**Category:** Elasticsearch\
**Created:** [January 19, 2018, 4:59am UTC](https://discuss.elastic.co/t/slice-the-aggregation/116160 "2018-01-19T04:59:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dheeran](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@dheeran](https://discuss.elastic.co/u/dheeran)\
**Post date:** [January 19, 2018, 4:59am UTC](https://discuss.elastic.co/t/slice-the-aggregation/116160/1 "2018-01-19T04:59:21Z")

</div>

Hi guys,

I want to paginate the aggregation, so I decided to use partition filter for my case.

1. Is it the right decision?
2. How to assign "num\_partitions " dynamically using "cardinality" in a single query?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 19, 2018, 10:49am UTC](https://discuss.elastic.co/t/slice-the-aggregation/116160/2 "2018-01-19T10:49:04Z")

</div>

> [@dheeran](#):
>
> Is it the right decision?

We also now have a [composite aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html) too which relies on using a particular sort order and passing an `after` parameter to make repeated calls, each time asking for N results "after" whatever was the last item you unpacked in the last N results.

> [@dheeran](#):
>
> How to assign "num\_partitions " dynamically using "cardinality" in a single query?

You can't. We currently don't have a single query that makes these sorts of multiple requests on your behalf.

---

<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:** [February 16, 2018, 10:49am UTC](https://discuss.elastic.co/t/slice-the-aggregation/116160/3 "2018-02-16T10:49:09Z")

</div>

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