Pagination problems

Hey :wave:

I’m having trouble understanding how to best implement a pagination widget:


I’ve hooked up all the logic, and everything works - except for the ‘go to last’ button.

There are 11731 items, and a page size of 30 which gives a pageNumber of 392 where the last page will only have 1 item.

However, whenever I refine(newPage) with a number above 34, I get the error

{"results":[{"hits":[],"page":392,"nbHits":0,"nbPages":0,"hitsPerPage":30,"exhaustiveNbHits":true,"processingTimeMS":1,"message":"you can only fetch the 1000 hits for this query. You can extend the number of hits returned via the paginationLimitedTo index parameter or use the browse method. You can read our FAQ for more details about browsing:","query":"","params":...}]}

Using the prebuilt pagination widget with showLast

<Pagination showLast={true} showFirst={true} />

also only allows to fetch 34 pages:


So, a couple of questions:

  1. Does this mean that Algolia has already fetched 1000 records and are paginating them clientside? If so, that isn’t really what I want. I’d want it to fetch a max of 2-3 times page size (so under 100), and then perform a new network request when the client navigates to pages outside the cached items.
  2. How do I implement the goToLast button using the Pagination connector widget?

Getting a minimal reproducible example makes it easier for us to help you. We provide a CodeSandbox templat​e to avoid spending time setting up the environment. Please get back to us with the sandbox link.

There’s no code to exemplify here, only two questions :smile: One for clarity, one for help.

How would you implement a ‘Go to last page’ button in the sandbox you linked? There should be

746+633+591+530+442+394+350+320+218+298 = 4522 items

in the search set, and with a page size of 20 there should be 227 pages. I’m asking for help on how to implement a button that goes to the last page by using the Pagination connector :slight_smile: Thanks


The error message you provided explains why you cannot get past the page 34. For performance reasons Algolia fetches at most 1000 documents. This value is configurable in the setting paginationLimitedTo but at the cost of performances. See You are limited to the page 34 because this is the last page that contains the last hits of the 1000 allowed (34 * 30 = 1020).
If you’re using InstantSearch.js there’s a widget that implement this feature: But it is still limited to paginationLimitedTo.

The browse feature of Algolia could allow this to be achieved fully: But we don’t recommend using it to build a search UI: the experience wouldn’t be as great as a search experience and some features are also limited.

Could you describe your use case where you need to expose 10000 documents in the result list of as search?

Kind regards.

Hey @jose-paul.dominguez :smile:

If I were to change the value, I’d set it lower than 1000, not higher :smile: As mentioned in my OP, I’d rather set it towards a 100.

However, I would assume that I could pass a page number to the connector, and it would then fetch the items relevant for that page number and size based on the search set over the network instead of from the cache. I totally understand the limit on the cache size, but I don’t understand why the rest of the search set shouldn’t be possible to fetch on demand? :smile:

For now I’ll just hide the ‘go to last’ button until the filtered set is < cache size (1000)