How can I retrieve all documents at once? When `fo...
# community-help
m
How can I retrieve all documents at once? When
found
was 2000,
hits
was 10. I just could retrieve 10 documents.
h
You can only get at max of 250 documents in page. Try increasing
per_page
parameter to 250 and to get the next page update
page
parameter. https://typesense.org/docs/0.20.0/api/documents.html#arguments
m
So, should I continue increasing page one by one for each query until I get all documents?
Are there any queries to get all documents at once? like, firestore().collection().get();
k
If all you want is to get all the documents in the collection, use the export endpoint.
👀 1
But if you want to get all results matching a query, then paginating is the only way. However, note that, it is likely to be slow as you paginate more and more because of the underlying sorting involved. We're thinking of adding a query + export feature that will alleviate this issue.
👏 1
m
Awesome
r
@Kishore Nallan why will paginate keep slowing as you paginate more and more? Can you elaborate a bit more? Does that mean then that it's not really feasible for a user to scroll through all the results in a search query?
m
When are you going to implement the feature?
k
In the backlog, not prioritized yet.
m
ok
Or if possible, increasing limit of per_page is really helpful.
k
Can you elaborate a bit more?
Does that mean then that it's not really feasible for a user to scroll through all the results in a search query?
@Ricardo Only when the scroll length reaches few thousand documents or more. Typesense is a search engine primarily and so optimized for search rather than scroll use cases.
Or if possible, increasing limit of per_page is really helpful.
We have that limit to prevent abuse (sigh!). I don't think we can change that.
👍 1
r
@Kishore Nallan but doesn't scrolling through a search fit into that use case?
Do you mind sharing some details about the implementation, that makes it slow for paging/scrolling?
k
Yes, but seldom do search engines allow you to scroll through millions of results. For e.g. Google limits you to 10-20 pages. Hundreds of pages is fine, though and the total data set size also matters.