You may notice that when reviewing your index in the Algolia Dashboard, or on your InstantSearch frontend, that the number of hits returned by a query don't tally with the counts next to some of your facets.
If this is the case, check whether the facet showing the incorrect count is set to 'after distinct' as an attribute for faceting.
Setting 'after distinct' on an attribute for faceting means that facet counts will be calculated after distinct has been applied. Distinct is a method used to Group Results and is often employed in cases where you want to combine records into a single result, rather than displaying each variant as a separate hit. For example, you might have 5 records for the same t-shirt, one for each size the t-shirt is available in.
The issue occurs when combining this with disjunctive faceting. Disjunctive faceting allows for the selection of multiple values within the same facet and to filter on them independently (e.g. size is Medium OR Large). It's the opposite of conjunctive faceting, where the values are treated as dependent (e.g. Medium AND Large).
To allow for disjunctive faceting, InstantSearch makes two requests; one to retrieve the hits and one to retrieve the facets. The request to retrieve the facets, counts the deduplicated hits before they have been filtered, and this is what can lead to inconsistencies between the hits and the facet counts.
This is a limitation of InstantSearch and the only way to ensure consistent counts under these circumstances is to use conjunctive faceting instead. This can be enabled within your InstantSearch refinementList widget by changing the operator parameter value to 'AND'. There's no way to do this within the Algolia Dashboard.
If the circumstances outlined here do not match your application, but you're still seeing inaccurate facet counts, the issue might be explained in one of these articles: