DateHistogramResult example

$date = new \DateTime($key);

            if ($dateFormat = $aggregation->getFormat()) {
                $value = $date->format($dateFormat);
            } else {
                $value = EntityAggregator::formatDate($aggregation->getInterval()$date);
            }

            $buckets[] = new Bucket($value$bucket['doc_count']$nested);
        }

        return new DateHistogramResult($aggregation->getName()$buckets);
    }

    private function hydrateTermsAggregation(TermsAggregation $aggregation, array $result, Context $context): ?TermsResult
    {
        if ($aggregation->getSorting()) {
            return $this->hydrateSortedTermsAggregation($aggregation$result$context);
        }

        if (isset($result[$aggregation->getName()])) {
            $result = $result[$aggregation->getName()];
        }

        
/** * @param array<array<string, mixed>> $rows */
    private function hydrateDateHistogramAggregation(
        DateHistogramAggregation $aggregation,
        EntityDefinition $definition,
        array $rows,
        Context $context
    ): DateHistogramResult {
        if (empty($rows)) {
            return new DateHistogramResult($aggregation->getName()[]);
        }

        $buckets = [];

        $grouped = $this->groupBuckets($aggregation$rows);

        foreach ($grouped as $value => $group) {
            $count = $group['count'];
            $nested = null;

            if ($aggregation->getAggregation()) {
                
Home | Imprint | This part of the site doesn't use cookies.