if (!
$criteria->
getGroupFields()) { $array =
$search->
toArray();
$array['timeout'
] =
$this->timeout;
return $array;
} $aggregation =
$this->
buildTotalCountAggregation($criteria,
$definition,
$context);
$search->
addAggregation($aggregation);
$array =
$search->
toArray();
$array['collapse'
] =
$this->
parseGrouping($criteria->
getGroupFields(),
$definition,
$context);
$array['timeout'
] =
$this->timeout;
return $array;
} /**
* @param FieldGrouping[] $groupings
*
* @return array{field: string, inner_hits?: array{name: string}}
*/
private function parseGrouping(array
$groupings, EntityDefinition
$definition, Context
$context): array
{