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

Can be used in these methods:

About this parameter

Compute facet counts after deduplication (via the distinct setting).

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

  • facetingAfterDistinct applies to all faceted attributes. To affect specific attributes, use the afterDistinct modifier.

  • To avoid inconsistent facet counts, don’t use facetingAfterDistinct if you don’t have the same facet values in all records sharing the same distinct key. Use the afterDistinct attribute modifier instead.

  • If facetingAfterDistinct is set to true, it takes precedence over afterDistinct.

  • facetingAfterDistinct can only be set at query time. You can’t add it as a default setting of the index.

Examples

Enable facetingAfterDistinct

1
2
3
$results = $index->search('query', [
  'facetingAfterDistinct' => true
]);
Did you find this page helpful?