1 | <?php |
||
23 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-adjacency-matrix-aggregation.html |
||
24 | */ |
||
25 | class AdjacencyMatrixAggregation extends AbstractAggregation |
||
26 | { |
||
27 | const FILTERS = 'filters'; |
||
28 | |||
29 | use BucketingTrait; |
||
30 | |||
31 | private array $filters = [ |
||
|
|||
32 | self::FILTERS => [] |
||
33 | ]; |
||
34 | |||
35 | public function __construct(string $name, array $filters = []) |
||
36 | { |
||
37 | parent::__construct($name); |
||
38 | |||
39 | foreach ($filters as $name => $filter) { |
||
40 | $this->addFilter($name, $filter); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @throws \LogicException |
||
46 | */ |
||
47 | public function addFilter(string $name, BuilderInterface $filter): static |
||
48 | { |
||
49 | $this->filters[self::FILTERS][$name] = $filter->toArray(); |
||
50 | |||
51 | return $this; |
||
52 | } |
||
53 | |||
54 | public function getArray(): array |
||
55 | { |
||
56 | return $this->filters; |
||
57 | } |
||
58 | |||
59 | public function getType(): string |
||
60 | { |
||
61 | return 'adjacency_matrix'; |
||
62 | } |
||
63 | } |
||
64 |