raffffffff
raffffffff

Reputation: 3537

Algolia browse function not accepting filters

I am using the browse function on results more than 1000.

I am passing facetFilters in the first index.browse call. This returns a cursor. I then use this cursor in my index.browseFrom function.

This returns a result which I think is correct, however, nbHits and nbPages are not shown in the returned response.

Below is what I am trying to do:

index.browse(keyword, {
   hitsPerPage: 20,
   facetFilters: 'category:testCategory AND brand:testBrand'
}, function (err, content) {
   index.browseFrom(content.cursor, function (err, content) {
     vm.results.listings = content.hits;
     vm.results.totalResults = content.nbHits;
     vm.results.pages = content.nbPages;
     vm.results.hitsPerPage = content.hitsPerPage;
     vm.noResults = (content.hits == 0);
     vm.loading = false;
});

Upvotes: 0

Views: 187

Answers (1)

redox
redox

Reputation: 2319

For performance reason, the nbHits & nbPages attributes are not computed during a browse: it has really been designed to iterate over the whole content of an index.

If this is used for end-users, you can go for a "Load more" button instead of a regular pagination.

Upvotes: 1

Related Questions