I guess it will depend on which version you are using, but for Elasticsearch 8.4 the recommendation is:
We no longer recommend using the scroll API for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the
search_afterparameter with a point in time (PIT).