Pagination and Determining Next Page
TLDR Gustavo asked about pagination and determining the next page. Jason suggested using the found
, per_page
, and page
keys to calculate the total number of pages.
Powered by Struct AI
4
6mo
Jun 14, 2023 (6 months ago)
Gustavo
Gustavo
04:46 PMRegarding pagination, what's the recommended way to know if there's a next page?
Jason
Jason
04:49 PMThe response will contain a
found
key with the total number of documents across all pages.04:49
Jason
04:49 PMYou’d use that along with the
per_page
and page
search parameters to determine the total number of pagesGustavo
Gustavo
04:50 PMThanks, will do that. It only works though if
per_page
is always the same. One could want to have the first page have fewer items to load faster, and in that case it would involve a bit more math, so a has_more
could be nice. But your suggestion will work for me.Typesense
Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI
Indexed 3015 threads (79% resolved)
Similar Threads
How to Check Next Page Existence When Paginating
Patrik inquired about checking next page when paginating. Jason suggested using the 'found' field from the response and 'per_page' query value.
3
14mo
Calculating Total Pages in Search Request Results
Laura asked how to calculate total pages of search results. Jason suggested using `found / per_page`.
4
6mo
Pagination of Data with Different Page Sizes
Jameshwart inquires about pagination with different page sizes. Jason advises on pagination using 'per_page', 'found', and 'modulo'. Kishore Nallan suggests using 'offset' and 'limit' for flexible pagination.
13
4mo