You use a search method that returns the first n queries for the query.
There are other (lower-level) methods that do not have restrictions, and the documentation says that "applications should use this method if they need all the relevant documents. High-level search APIs (search (Query, int)) are usually more efficient, as he misses invisible hits. "
So, if you really need all the documents, you can use the low-level API. I doubt it matters a lot in performance for conveying a really high limit API high level. If you need all the documents (and there are really a lot of them), they will be slow anyway, especially when sorting.
source share