attributeForDistinct
null
'attributeForDistinct' => 'attribute'
Can be used in these methods:
setSettings
set_settings
setSettings
set_settings
setSettings
setSettings
SetSettings
setSettings
SetSettings
setSettings
About this parameter
Name of the attribute to deduplicate or group records.
The attributeForDistinct attribute works in combination with distinct:
attributeForDistinctestablishes groups: all records with the same value ofattributeForDistinctare treated as a group.distinctdetermines how many variants per group are included in the search results.
Usage notes
- 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. - The
attributeForDistinctattribute expects strings or numbers as values:- Number values are rounded to the nearest integer and converted to their string representation,
for example,
1and1.2both turn into"1". - 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,
Examples
Set the attribute to distinct
The following example declares the url attribute as attributeForDistinct.
To deduplicate or group records based on this attribute, you also have to set the distinct parameter.
1
2
3
$index->setSettings([
'attributeForDistinct' => 'url'
]);