Hi guys, this is not really a ts question but just...
# community-help
j
Hi guys, this is not really a ts question but just want to ask if anyone of you have done a pagination of ts data where the first page is like 15 results and the next page and rest of the page pages is 18? any guide to this would be appreciated. Thank you
j
Hmm! You can control the page size using the
per_page
search parameter, and every page should have that many number of hits, except for the last page which might have less than that
Are you seeing different number of results as you paginate using
page
and
per_page
for the same query?
j
the problem is calculating the pages and what would be the next page result.
because page 2 if per_page is 15 is different to page 2 for per_page is 18
j
There’s a field called
found
in the response. If do divide
found / per_page
you’ll get the total number of pages
If you do
found MODULO per_page
you’ll get the number of results on the last page
j
that is what I am currently doing.
j
Not sure I understand the issue…
Any reason you’re changing
per_page
between pages?
j
no special reason. that just the requirement. load first 15 then on load more is 18.
actually that is because we had an item inserted in the first page load(3 items) so in load more result we need to get 18 result
k
In 0.25 RC we also have offset based pagination. Instead of using
page
and
per_page
you can use
offset
and
limit
(like SQL) and this offers flexible pagination.