Bucket example

$nested = $this->hydrateResult($aggregation->getAggregation()$definition$group['buckets']$context);
            }

            $date = new \DateTime($value);

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

            $buckets[] = new Bucket($value$count$nested);
        }

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

    /** * @param array<array<string, mixed>> $rows */
    private function hydrateTermsAggregation(
        TermsAggregation $aggregation,
        EntityDefinition $definition,
        

    }

    /** * check that matrix calculates correctly * * @group reviews */
    public function testMissingAggregations(): void
    {
        $stars = [
            new Bucket('1.2', 3, null),
            new Bucket('2.0', 3, null),
            new Bucket('4.0', 3, null),
        ];

        $matrix = new RatingMatrix($stars);

        static::assertCount(5, $matrix->getMatrix());
        static::assertEquals(2.4, round($matrix->getAverageRating(), 1));
        static::assertEquals(9, $matrix->getTotalReviewCount());
        static::assertEquals(21.6, $matrix->getPointSum());
    }

    
new PropertyGroupOptionCollection(),
        ]$definition);

        $handler = new PropertyListingFilterHandler($repository$this->createMock(Connection::class));

        $result = new ProductListingResult(
            'test',
            1,
            new ProductCollection(),
            new AggregationResultCollection([
                new TermsResult('properties', [
                    new Bucket('red', 1, null),
                    new Bucket('green', 1, null),
                ]),
                new TermsResult('options', [
                    new Bucket('xl', 1, null),
                    new Bucket('l', 1, null),
                ]),
            ]),
            new Criteria(),
            Context::createDefaultContext()
        );

        
$key = $bucket['key'][$aggregation->getName() . '.key'];

            $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);
        }

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