# Adjust scroll size dynamically

**URL:** <https://discuss.elastic.co/t/adjust-scroll-size-dynamically/142992>\
**Category:** Elasticsearch\
**Created:** [August 3, 2018, 11:09pm UTC](https://discuss.elastic.co/t/adjust-scroll-size-dynamically/142992 "2018-08-03T23:09:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![willhcurtin](https://avatars.discourse-cdn.com/v4/letter/w/f0a364/32.png) [@willhcurtin](https://discuss.elastic.co/u/willhcurtin)\
**Post date:** [August 3, 2018, 11:09pm UTC](https://discuss.elastic.co/t/adjust-scroll-size-dynamically/142992/1 "2018-08-03T23:09:32Z")

</div>

Hi all,

I was wondering if there it is possible to reduce the size of a scroll search dynamically.

I am using Elasticsearch 2.3. I am coding in Java if that helps.

My use case:  
I am trying to move items from my ES cluster to another storage and one query can contain up to ~40million items. Long story short, I am running the compute/query on AWS Lambda and I am chaining a bunch of these Lambda functions passing the scrollId until the entire scroll query is complete. Pseudocode encompassing the idea:

if (scrollId is not null):  
(records, scrollId) = scrollSearch(scrollId)  
writeRecordsToOtherStorage(records)  
startNextLambda(newScrollId)

The problem arises in that Lambda has a fixed time limit of 5 minutes. Since the records are not fixed length, In some cases, the task cannot complete in 5minutes. In these cases, when I am retrying, I want to be able to reduce the scroll size in half at whatever point I am in the search. For example, if I am starting a Search A with size = N, and after the 10th Lambda it fails, I want to be redo that Lambda with size N/2. The redo logic is all in place and fine, it is just that I cannot change the scroll size when restarting that Lambda.

I appreciate any feedback. Thank you in advance!

---

<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:** [August 31, 2018, 11:09pm UTC](https://discuss.elastic.co/t/adjust-scroll-size-dynamically/142992/2 "2018-08-31T23:09:35Z")

</div>

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