# CompositeAggregation pagination's consistent behavior during indexing being frequently update period

**URL:** <https://discuss.elastic.co/t/compositeaggregation-paginations-consistent-behavior-during-indexing-being-frequently-update-period/245155>\
**Category:** Elasticsearch\
**Created:** [August 16, 2020, 4:01pm UTC](https://discuss.elastic.co/t/compositeaggregation-paginations-consistent-behavior-during-indexing-being-frequently-update-period/245155 "2020-08-16T16:01:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slodevppw](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@slodevppw](https://discuss.elastic.co/u/slodevppw)\
**Post date:** [August 16, 2020, 4:01pm UTC](https://discuss.elastic.co/t/compositeaggregation-paginations-consistent-behavior-during-indexing-being-frequently-update-period/245155/1 "2020-08-16T16:01:58Z")

</div>

We recently use ES CompositeAggregation to generate a report, which requires sorting and the result (can up-to 1M records sometime) is large which requires pagination.

However, duplicated records have been identified (certain record has been duplicate like 10times) and I am trying to understand the consistent behavior during pagination for CompositeAggregation, especially when index is being frequently updated or deleted.

I notice regular indexing rate is at 70TPS which mainly updates on current month index, there's ongoing backfill which introduced extra 70TPS which can be on any random monthly indices).

I have a few questions:

- Does CompositeAggregation generate consistent report during pagination?
- Under the hood, how does after\_key work?
- I know there's Scan search or Scroll search. Scan search won't fit for our use case since it's our data needed to be sorted. In case we favor consistent behavior of reporting, would Scroll API be a better option? what's the pro/cons between Scroll vs CompositeAggregation?

---

<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:** [September 13, 2020, 4:02pm UTC](https://discuss.elastic.co/t/compositeaggregation-paginations-consistent-behavior-during-indexing-being-frequently-update-period/245155/2 "2020-09-13T16:02:04Z")

</div>

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