To download all documents from an index, first you need to create a search ID:
curl -X POST "localhost:9200/<indexName>/_search?scroll=5m&pretty&size=10000"
This will keep a search session for 5 minutes
Then, send another query to scroll through the pages of data until there is no more:
curl -X GET "localhost:9200/_search/scroll?pretty&scroll=5m&scroll_id=<searchIdFromThePreviousStep>"