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

Can be used in these methods:

About this parameter

Force faceting to be applied after de-duplication (via the Distinct setting).

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.

Usage notes

  • You should not use facetingAfterDistinct=true if you don’t have the same facet values in all records sharing the same distinct key (you would get inconsistent results).

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

  • The facet count is based on the number of hits the engine finds. This means that when using the distinct parameter to group results (with a numeric value greater than zero), the facet count isn’t based on the group itself, but on the hits that make up this group.


Enable facetingAfterDistinct

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