SlicedScroll illustrates scrolling through a set of documents in parallel. It uses the sliced scrolling feature introduced in Elasticsearch 5.0 to create a number of Goroutines, each scrolling through a slice of the total results. A second goroutine receives the hits from the set of goroutines scrolling through the slices and simply counts the total number and the number of documents received per slice.
The speedup of sliced scrolling can be significant but is very dependent on the specific use case.
See https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-scroll.html#sliced-scroll for details on sliced scrolling in Elasticsearch.
Scroll with 4 parallel slices through an index called "products". Use "_uid" as the default field:
sliced_scroll -index=products -n=4