How to get only top 50 records in the response

Hello All,
We have a requirement to show the top 50 best selling products based on revenue. We have created a replica on revenue so that the products can be shown,. But then all the products are coming up. Actually i need to restrict the total number of best sellers to be shown as 50 only such that the nbHits should show 50.
Any thoughts/inputs on this will really be helpful.


You can limit the results to the first 50 by setting hitsPerPage without a pagination widget:

(ps – I stole this idea from this older post: Limiting search result return to fixed number of results)

But I am looking for a way where i can limit the nbHits since I need to limit the nbHits to only 50 (to show only the top 50 best selling products).
This is mainly needed since we will show the text which populates dynamically from the fields:
Showing 10 of 50. where 10 comes from hitsPerPage and 50 comes from nbHits

So i need the total records to be shown as 50.

Got it, you actually want to use Pagination, so you can’t use it to limit hits in this use case. We don’t have a setting for limiting the total number of results.

What are you using as the ranking criteria for the products? Could you build a filter around that (i.e. add a “rank” attribute to your records and use a numeric to just filter the top 50.

The more we talk about this, the more it feels like an interesting use case for our Trending models in Recommend, but those require you to be sending conversion events.