API Reference / API Parameters / facetingAfterDistinct
Type: boolean
Engine default: false
Parameter syntax
'facetingAfterDistinct' => true|false

Can be used in these methods:

About this parameter

Apply faceting after deduplication (via the distinct setting).

If you want to use faceting in combination with deduplication or grouping (distinct), you should use the afterDistinct modifier in your attributesForFaceting. This only affects a single attribute. facetingAfterDistinct affects all attributes.

If you’re using the distinct setting in combination with faceting, facet counts may be higher than expected. By default, Algolia computes faceting before deduplicating records (distinct). When facetingAfterDistinct is set to true, Algolia calculates faceting after deduplicating.

Usage notes

  • To avoid inconsistent results when the records sharing the same distinct key don’t have the same facet values, use the afterDistinct
  • If you have the same facet values in all records sharing the same distinct key, you can use facetingAfterDistinct=true.
  • facetingAfterDistinct can only be set at query time. You can’t add it as a default setting of the index.


Enable facetingAfterDistinct

$results = $index->search('query', [
  'facetingAfterDistinct' => true
Did you find this page helpful?