Stats component does not show the total number of results in a multiple indexes search #6347
-
Hi! I'm using React InstantSearch to search multiple indexes in Algolia. I need to display the total number of results on top of my search page and I've understood that the Stats component is the way to go. Unfortunately it only shows the results for the default index set in Is this as intended? Is there a workaround to show the total amount? Many thanks! This is what I have:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
stats is only designed for a single index. A solution is using function TotalStats() {
const { scopedResults, results } = useInstantSearch();
const totalNbHits = scopedResults.reduce((total, current) => total + current.results.nbHits, 0)
return <p>found {totalNbHits} in {results.processingTimeMS}ms</p>
} |
Beta Was this translation helpful? Give feedback.
stats is only designed for a single index. A solution is using
useInstantSearch
: