Get total number of hits before filters etc


I’m looking to get the total number of hits before filters have been applied. Is it possible? I’ve looked into creating a custom connector but even then it seems to decrease the number of nbHits when a filter is applied.

Hi @kris,

Are you looking for displaying this total number of hits without filter even though some filters are applied?

@marielaure.thuret Yes, that’s right :slight_smile:

We are doing an empty query when the app first render. You coup keep the hit number available in the stats widget somewhere in your state.

Would that work?

I don’t think that would do it, unfortunately. Filters can be applied to my search page on mount through the URL (something like search?query=asdf&refinementList[type][0]=qwerty). The stats widget and connector both seem to return the number of results after such a refinement.

So in that case, I believe that you’ll need a second InstantSearch component with just the hits, then you retrieve the number of hits and use that into your main InstantSearch component.