About this parameter
Name of the attribute to deduplicate or group records.
attributeForDistinct attribute works in combination with
attributeForDistinctestablishes groups: all records with the same value of
attributeForDistinctare treated as a group.
distinctdetermines how many variants per group are included in the search results.
- You can define only one attribute for distinct.
- You can only set
attributeForDistinctat indexing time. You can’t set or override it at query time.
attributeForDistinctattribute expects strings or numbers as values:
- Number values are rounded to the nearest integer and converted to their string representation,
1.2both turn into
- String values are used as they are.
- Boolean or null values are ignored.
- Array and object values aren’t supported and result in unspecified behavior.
- Number values are rounded to the nearest integer and converted to their string representation, for example,
Set the attribute to distinct
The following example declares the
url attribute as
To deduplicate or group records based on this attribute, you also have to set the
1 2 3 $index->setSettings([ 'attributeForDistinct' => 'url' ]);