1 | <?php |
||
23 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-autodatehistogram-aggregation.html |
||
24 | */ |
||
25 | class AutoDateHistogramAggregation extends AbstractAggregation |
||
26 | { |
||
27 | use BucketingTrait; |
||
28 | |||
29 | public function __construct( |
||
30 | private string $name, |
||
|
|||
31 | private string $field, |
||
32 | private ?int $buckets = null, |
||
33 | private ?string $format = null |
||
34 | ) { |
||
35 | parent::__construct($name); |
||
36 | |||
37 | $this->setField($field); |
||
38 | |||
39 | if ($buckets) { |
||
40 | $this->addParameter('buckets', $buckets); |
||
41 | } |
||
42 | |||
43 | if ($format) { |
||
44 | $this->addParameter('format', $format); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | public function getArray(): array |
||
49 | { |
||
50 | return array_filter( |
||
51 | [ |
||
52 | 'field' => $this->getField(), |
||
53 | ] |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | public function getType(): string |
||
58 | { |
||
59 | return 'auto_date_histogram'; |
||
60 | } |
||
61 | } |
||
62 |