Pagination not working

I created a stackoverflow question but then updated to v2 of instantsearch but pagination still isn’t working.

So, this is InstantSearch v2:

cpSearch = instantsearch({
    appId: appId,
    apiKey: apiKey,
    indexName: cpListIndexname,
    urlSync: false,
    searchParameters: {
        hitsPerPage: 500
    }
});

cpSearch.addWidget(
    instantsearch.widgets.searchBox({
        container: '#search-box',
        placeholder: 'Search for a Project'
    })
);

cpSearch.addWidget(
    instantsearch.widgets.hits({
        container: '#hits-container',
        templates: {
            item: getMustacheTemplate('hit'),
            empty: getMustacheTemplate('no-results')
        }
    })
);

cpSearch.addWidget(
    instantsearch.widgets.pagination({
        container: '#cp-pagination-container'
    })
);

cpSearch.on('render', callBack);
cpSearch.start();

The problem is this:

There are 1,878 object in the index. When the search starts, I am presented with 500 hits and the pagination shows 1, 2. But the pagination should show 1 (containing 1-500), 2 (containing 501-1000), 3 (containing 1001 - 1500), 4 (containing 1501 - 1878).

What is going on here?

Hello @ecoffman,

By default, Algolia limits the maximum number of hits that can be retrieved via a query to 1000. You can bypass that by updating the paginationLimitedTo setting of your index.

You can read more why we limit to 1000 hits by default here.

Thanks for your question, I hope I could help you. Feel free to ask us anything else!

Cheers, Maxime.

1 Like