$fieldName =
$this->
buildAccessor($definition,
$aggregation->
getField(),
$context);
return $this->
createAggregation($aggregation,
$fieldName,
$definition,
$context);
} private function createAggregation(Aggregation
$aggregation, string
$fieldName, EntityDefinition
$definition, Context
$context): AbstractAggregation
{ if ($this->keyValueStorage->
get(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, false
)) { $field =
$this->
getField($definition,
$fieldName);
if ($field instanceof TranslatedField
) { $fieldName =
$this->
getTranslatedFieldName($fieldName,
$context->
getLanguageId());
} } return match (true
) { $aggregation instanceof StatsAggregation =>
$this->
parseStatsAggregation($aggregation,
$fieldName,
$context),
$aggregation instanceof AvgAggregation =>
new Metric\
AvgAggregation($aggregation->
getName(),
$fieldName),
$aggregation instanceof EntityAggregation =>
$this->
parseEntityAggregation($aggregation,
$fieldName),
$aggregation instanceof MaxAggregation =>
new Metric\
MaxAggregation($aggregation->
getName(),
$fieldName),
$aggregation instanceof MinAggregation =>
new Metric\
MinAggregation($aggregation->
getName(),
$fieldName),
$aggregation instanceof SumAggregation =>
new Metric\
SumAggregation($aggregation->
getName(),
$fieldName),
$aggregation instanceof CountAggregation =>
new ValueCountAggregation($aggregation->
getName(),
$fieldName),