Skip to main content
  • Type: boolean
  • Default: false
  • Scope: search
By default, Algolia calculates facet counts before applying the distinct setting. This can lead to higher facet counts than expected. When facetingAfterDistinct is true, facet counts are computed after applying distinct, giving counts based only on distinct records.

Usage

  • Applies to all facet attributes.
  • To apply this behavior selectively, use the afterDistinct modifier in attributesForFaceting.
  • If both facetingAfterDistinct and afterDistinct are used, facetingAfterDistinct overrides the attribute-level setting.
  • Only use this setting if all records sharing the same distinct key have identical facet values—otherwise facet counts may appear inconsistent.

Example

Current API clients

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "query", FacetingAfterDistinct = true })
);
index.Search(new Query("query")
{
    FacetingAfterDistinct = true
});
I