The number of pages that are returned by a query is calculated as the maximum number of hits accessible through pagination divided by the number of hits per page, rounded up, (paginationLimitedTo/hitsPerPage = nbPages).
The maximum number of hits accessible through pagination is set through the paginationLimitedTo parameter and limits the number of search results (hits). The default value is 1000.
For example, if you receive the following numbers in response to a search query, you might wonder why the hitsPerPage value(10) multiplied by nbPages value(100) is fewer than the nbHits value(1500).
- nbHits = 1500
- hitsPerPage = 10
- nbPages = 100
This is because the Algolia engine picks up the top 1000 hits based on the pagenationLimitedTo parameter setting and returns pages based on that number, while the engine finds 1500 hits in the index in total.
You can increase the pagenationLimitedTo parameter if necessary, via API or in the Dashboard at "Indices" > "Configuration" > "Pagination".
Please note that users usually refine search results instead of browsing 100 pages, so increasing the value doesn't always improve the search user's experience.
Important usage notes#
- Higher pagination limits might slow down your search. Set the pagination limit only as high as you need.
- Lower pagination limits make extracting all your data (scraping) more difficult.
- The maximum value for this parameter is 20,000.
- For pagination limits above 1,000, the sorting of results beyond the 1,000th hit can’t be guaranteed.