I prefer to run this query { "query": { "match_all": {} }, "size": 5000, "from": 0 }
then i will doing loop for next page (by modifiying from clause) for next page.
Anyway, you can check how much the exact total docs you have in the response { "took": 94, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": 852705, "max_score": 1,...}} in my case i have 852705 document