When using the distinct setting in combination with faceting, facet counts may be higher than expected. This is because the engine, by default, computes faceting before applying de-duplication (distinct). When facetingAfterDistinct
is set to true, the engine calculates faceting after the de-duplication has been applied.
To test this functionality on your Algolia dashboard and to get the correct results in both facets and hit results, you would need to set the facetingAfterDistinct
parameter to true. You can do that by selecting "Add Query Paramater" on your Algolia dashboard and passing the facetingAfterDistinct
parameter to custom search parameters.
Keep in mind, facetingAfterDistinct
can only be set at query time; it can’t be added as a default setting of the index. You can set this setting at query time when the request is made on your website.
There are several scenarios that could lead to incorrect or inconsistent facet counts. If this article doesn't relate to your issue, please check our other guides on this topic:
Why don't my facet counts match the number of hits for attributes set to 'after distinct'?
Inconsistent facet counts with facetingAfterDistinct