| @@ 11-75 (lines=65) @@ | ||
| 8 | * |
|
| 9 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html |
|
| 10 | */ |
|
| 11 | class AvgBucket extends AbstractAggregation |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param string $name |
|
| 15 | * @param string|null $bucketsPath |
|
| 16 | */ |
|
| 17 | public function __construct($name, $bucketsPath = null) |
|
| 18 | { |
|
| 19 | parent::__construct($name); |
|
| 20 | ||
| 21 | if ($bucketsPath !== null) { |
|
| 22 | $this->setBucketsPath($bucketsPath); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Set the buckets_path for this aggregation. |
|
| 28 | * |
|
| 29 | * @param string $bucketsPath |
|
| 30 | * |
|
| 31 | * @return $this |
|
| 32 | */ |
|
| 33 | public function setBucketsPath($bucketsPath) |
|
| 34 | { |
|
| 35 | return $this->setParam('buckets_path', $bucketsPath); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Set the gap policy for this aggregation. |
|
| 40 | * |
|
| 41 | * @param string $gapPolicy |
|
| 42 | * |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function setGapPolicy($gapPolicy) |
|
| 46 | { |
|
| 47 | return $this->setParam('gap_policy', $gapPolicy); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Set the format for this aggregation. |
|
| 52 | * |
|
| 53 | * @param string $format |
|
| 54 | * |
|
| 55 | * @return $this |
|
| 56 | */ |
|
| 57 | public function setFormat($format) |
|
| 58 | { |
|
| 59 | return $this->setParam('format', $format); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @throws InvalidException If buckets path or script is not set |
|
| 64 | * |
|
| 65 | * @return array |
|
| 66 | */ |
|
| 67 | public function toArray() |
|
| 68 | { |
|
| 69 | if (!$this->hasParam('buckets_path')) { |
|
| 70 | throw new InvalidException('Buckets path is required'); |
|
| 71 | } |
|
| 72 | ||
| 73 | return parent::toArray(); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| @@ 11-87 (lines=77) @@ | ||
| 8 | * |
|
| 9 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html |
|
| 10 | */ |
|
| 11 | class SerialDiff extends AbstractAggregation |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param string $name |
|
| 15 | * @param string|null $bucketsPath |
|
| 16 | */ |
|
| 17 | public function __construct($name, $bucketsPath = null) |
|
| 18 | { |
|
| 19 | parent::__construct($name); |
|
| 20 | ||
| 21 | if ($bucketsPath !== null) { |
|
| 22 | $this->setBucketsPath($bucketsPath); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Set the buckets_path for this aggregation. |
|
| 28 | * |
|
| 29 | * @param string $bucketsPath |
|
| 30 | * |
|
| 31 | * @return $this |
|
| 32 | */ |
|
| 33 | public function setBucketsPath($bucketsPath) |
|
| 34 | { |
|
| 35 | return $this->setParam('buckets_path', $bucketsPath); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Set the lag for this aggregation. |
|
| 40 | * |
|
| 41 | * @param int $lag |
|
| 42 | * |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function setLag($lag) |
|
| 46 | { |
|
| 47 | return $this->setParam('lag', $lag); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Set the gap policy for this aggregation. |
|
| 52 | * |
|
| 53 | * @param string $gapPolicy |
|
| 54 | * |
|
| 55 | * @return $this |
|
| 56 | */ |
|
| 57 | public function setGapPolicy($gapPolicy) |
|
| 58 | { |
|
| 59 | return $this->setParam('gap_policy', $gapPolicy); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Set the format for this aggregation. |
|
| 64 | * |
|
| 65 | * @param string $format |
|
| 66 | * |
|
| 67 | * @return $this |
|
| 68 | */ |
|
| 69 | public function setFormat($format) |
|
| 70 | { |
|
| 71 | return $this->setParam('format', $format); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * @throws InvalidException If buckets path is not set |
|
| 76 | * |
|
| 77 | * @return array |
|
| 78 | */ |
|
| 79 | public function toArray() |
|
| 80 | { |
|
| 81 | if (!$this->hasParam('buckets_path')) { |
|
| 82 | throw new InvalidException('Buckets path is required'); |
|
| 83 | } |
|
| 84 | ||
| 85 | return parent::toArray(); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| @@ 11-75 (lines=65) @@ | ||
| 8 | * |
|
| 9 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-stats-bucket-aggregation.html |
|
| 10 | */ |
|
| 11 | class StatsBucket extends AbstractAggregation |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param string $name |
|
| 15 | * @param string|null $bucketsPath |
|
| 16 | */ |
|
| 17 | public function __construct($name, $bucketsPath = null) |
|
| 18 | { |
|
| 19 | parent::__construct($name); |
|
| 20 | ||
| 21 | if ($bucketsPath !== null) { |
|
| 22 | $this->setBucketsPath($bucketsPath); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Set the buckets_path for this aggregation. |
|
| 28 | * |
|
| 29 | * @param string $bucketsPath |
|
| 30 | * |
|
| 31 | * @return $this |
|
| 32 | */ |
|
| 33 | public function setBucketsPath($bucketsPath) |
|
| 34 | { |
|
| 35 | return $this->setParam('buckets_path', $bucketsPath); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Set the gap policy for this aggregation. |
|
| 40 | * |
|
| 41 | * @param string $gapPolicy |
|
| 42 | * |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function setGapPolicy($gapPolicy) |
|
| 46 | { |
|
| 47 | return $this->setParam('gap_policy', $gapPolicy); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Set the format for this aggregation. |
|
| 52 | * |
|
| 53 | * @param string $format |
|
| 54 | * |
|
| 55 | * @return $this |
|
| 56 | */ |
|
| 57 | public function setFormat($format) |
|
| 58 | { |
|
| 59 | return $this->setParam('format', $format); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @throws InvalidException If buckets path or script is not set |
|
| 64 | * |
|
| 65 | * @return array |
|
| 66 | */ |
|
| 67 | public function toArray() |
|
| 68 | { |
|
| 69 | if (!$this->hasParam('buckets_path')) { |
|
| 70 | throw new InvalidException('Buckets path is required'); |
|
| 71 | } |
|
| 72 | ||
| 73 | return parent::toArray(); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| @@ 11-75 (lines=65) @@ | ||
| 8 | * |
|
| 9 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html |
|
| 10 | */ |
|
| 11 | class SumBucket extends AbstractAggregation |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param string $name |
|
| 15 | * @param string|null $bucketsPath |
|
| 16 | */ |
|
| 17 | public function __construct($name, $bucketsPath = null) |
|
| 18 | { |
|
| 19 | parent::__construct($name); |
|
| 20 | ||
| 21 | if ($bucketsPath !== null) { |
|
| 22 | $this->setBucketsPath($bucketsPath); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Set the buckets_path for this aggregation. |
|
| 28 | * |
|
| 29 | * @param string $bucketsPath |
|
| 30 | * |
|
| 31 | * @return $this |
|
| 32 | */ |
|
| 33 | public function setBucketsPath($bucketsPath) |
|
| 34 | { |
|
| 35 | return $this->setParam('buckets_path', $bucketsPath); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Set the gap policy for this aggregation. |
|
| 40 | * |
|
| 41 | * @param string $gapPolicy |
|
| 42 | * |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function setGapPolicy($gapPolicy) |
|
| 46 | { |
|
| 47 | return $this->setParam('gap_policy', $gapPolicy); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Set the format for this aggregation. |
|
| 52 | * |
|
| 53 | * @param string $format |
|
| 54 | * |
|
| 55 | * @return $this |
|
| 56 | */ |
|
| 57 | public function setFormat($format) |
|
| 58 | { |
|
| 59 | return $this->setParam('format', $format); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @throws InvalidException If buckets path or script is not set |
|
| 64 | * |
|
| 65 | * @return array |
|
| 66 | */ |
|
| 67 | public function toArray() |
|
| 68 | { |
|
| 69 | if (!$this->hasParam('buckets_path')) { |
|
| 70 | throw new InvalidException('Buckets path is required'); |
|
| 71 | } |
|
| 72 | ||
| 73 | return parent::toArray(); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||
| @@ 11-75 (lines=65) @@ | ||
| 8 | * |
|
| 9 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html |
|
| 10 | */ |
|
| 11 | class Derivative extends AbstractAggregation |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @param string $name |
|
| 15 | * @param string|null $bucketsPath |
|
| 16 | */ |
|
| 17 | public function __construct(string $name, string $bucketsPath = null) |
|
| 18 | { |
|
| 19 | parent::__construct($name); |
|
| 20 | ||
| 21 | if ($bucketsPath !== null) { |
|
| 22 | $this->setBucketsPath($bucketsPath); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Set the buckets_path for this aggregation. |
|
| 28 | * |
|
| 29 | * @param string $bucketsPath |
|
| 30 | * |
|
| 31 | * @return $this |
|
| 32 | */ |
|
| 33 | public function setBucketsPath(string $bucketsPath) |
|
| 34 | { |
|
| 35 | return $this->setParam('buckets_path', $bucketsPath); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Set the gap policy for this aggregation. |
|
| 40 | * |
|
| 41 | * @param string $gapPolicy |
|
| 42 | * |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function setGapPolicy(string $gapPolicy = 'skip') |
|
| 46 | { |
|
| 47 | return $this->setParam('gap_policy', $gapPolicy); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Set the format for this aggregation. |
|
| 52 | * |
|
| 53 | * @param string $format |
|
| 54 | * |
|
| 55 | * @return $this |
|
| 56 | */ |
|
| 57 | public function setFormat(string $format) |
|
| 58 | { |
|
| 59 | return $this->setParam('format', $format); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @throws InvalidException If buckets path or script is not set |
|
| 64 | * |
|
| 65 | * @return array |
|
| 66 | */ |
|
| 67 | public function toArray(): array |
|
| 68 | { |
|
| 69 | if (!$this->hasParam('buckets_path')) { |
|
| 70 | throw new InvalidException('Buckets path is required'); |
|
| 71 | } |
|
| 72 | ||
| 73 | return parent::toArray(); |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||