hydrateTermsAggregation example

if (isset($nestedResult[$nested->getName()])) {
                    $nestedResult = $nestedResult[$nested->getName()];
                }

                return $this->hydrateAggregation($nested$nestedResult$context);

            case $aggregation instanceof DateHistogramAggregation:
                return $this->hydrateDateHistogram($aggregation$result$context);

            case $aggregation instanceof TermsAggregation:
                return $this->hydrateTermsAggregation($aggregation$result$context);

            case $aggregation instanceof RangeAggregation:
                return $this->hydrateRangeAggregation($aggregation$result);

            default:
                throw new \RuntimeException(sprintf('Provided aggregation of class %s is not supported', $aggregation::class));
        }
    }

    private function hydrateEntityAggregation(EntityAggregation $aggregation, array $result, Context $context): EntityResult
    {
        
EntityDefinition $definition,
        array $rows,
        Context $context
    ): AggregationResult {
        $name = $aggregation->getName();

        switch (true) {
            case $aggregation instanceof DateHistogramAggregation:
                return $this->hydrateDateHistogramAggregation($aggregation$definition$rows$context);

            case $aggregation instanceof TermsAggregation:
                return $this->hydrateTermsAggregation($aggregation$definition$rows$context);

            case $aggregation instanceof FilterAggregation:
                $aggregationStruct = $aggregation->getAggregation();
                \assert($aggregationStruct !== null, 'FilterAggregation always have an aggregation');

                return $this->hydrateResult($aggregationStruct$definition$rows$context);

            case $aggregation instanceof AvgAggregation:
                $value = isset($rows[0]) ? $rows[0][$name] : 0;

                return new AvgResult($aggregation->getName()(float) $value);

            
Home | Imprint | This part of the site doesn't use cookies.