| 1 | <?php |
||
| 23 | class TermsAggregation extends AbstractAggregation |
||
| 24 | { |
||
| 25 | use BucketingTrait; |
||
| 26 | |||
| 27 | use ScriptAwareTrait; |
||
| 28 | |||
| 29 | public function __construct( |
||
| 30 | private string $name, |
||
|
|
|||
| 31 | private ?string $field = null, |
||
| 32 | ?string $script = null |
||
| 33 | ) { |
||
| 34 | parent::__construct($name); |
||
| 35 | |||
| 36 | $this->setField($field); |
||
| 37 | $this->setScript($script); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getType(): string |
||
| 41 | { |
||
| 42 | return 'terms'; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getArray(): array |
||
| 46 | { |
||
| 47 | return array_filter( |
||
| 48 | [ |
||
| 49 | 'field' => $this->getField(), |
||
| 50 | 'script' => $this->getScript(), |
||
| 51 | ] |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |