private function fetchAggregation( Aggregation
$aggregation,
EntityDefinition
$definition,
Criteria
$criteria,
Context
$context ): AggregationResult
{ $clone =
clone $criteria;
$clone->
resetAggregations();
$clone->
resetSorting();
$clone->
resetPostFilters();
$clone->
resetGroupFields();
// Early resolve terms to extract score queries
if ($clone->
getTerm()) { $pattern =
$this->interpreter->
interpret((string) $criteria->
getTerm());
$queries =
$this->scoreBuilder->
buildScoreQueries($pattern,
$definition,
$definition->
getEntityName(),
$context);
$clone->
addQuery(...
$queries);
$clone->
setTerm(null
);
} $scoreCriteria =
clone $clone;
$clone->
resetQueries();