# 230k aggregation trying to get an output

**URL:** <https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896>\
**Category:** Elasticsearch\
**Created:** [May 20, 2019, 8:11pm UTC](https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896 "2019-05-20T20:11:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [May 20, 2019, 8:11pm UTC](https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896/1 "2019-05-20T20:11:15Z")

</div>

Need some wisdom on aggregations.

I have around 230k aggregated IPs I am trying to aggregate and get them to a JSON file.

What would be the best way to do this in the ElasticSearch api?

using the scroll api?  
or just using search?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 24, 2019, 12:36pm UTC](https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896/2 "2019-05-24T12:36:42Z")

</div>

I'd use the [Composite aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html) to do that. It's essentially an aggregation that can page through the buckets, much like the scroll API can page through search hits.

It will be a lot more memory friendly than trying to aggregate all 230k IPs in one request 🙂

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [May 25, 2019, 7:11pm UTC](https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896/3 "2019-05-25T19:11:41Z")

</div>

Thank you!

I got a script written and it is working .

The whole last key thing through me for major loop.

---

<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:** [June 22, 2019, 7:11pm UTC](https://discuss.elastic.co/t/230k-aggregation-trying-to-get-an-output/181896/4 "2019-06-22T19:11:56Z")

</div>

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