1 | <?php |
||
22 | class RangeAggregation extends AbstractAggregation |
||
23 | { |
||
24 | use BucketingTrait; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $ranges = []; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | private $keyed = false; |
||
35 | |||
36 | /** |
||
37 | * Inner aggregations container init. |
||
38 | * |
||
39 | * @param string $name |
||
40 | * @param string $field |
||
41 | * @param array $ranges |
||
42 | * @param bool $keyed |
||
43 | */ |
||
44 | public function __construct($name, $field = null, $ranges = [], $keyed = false) |
||
57 | |||
58 | /** |
||
59 | * Sets if result buckets should be keyed. |
||
60 | * |
||
61 | * @param bool $keyed |
||
62 | * |
||
63 | * @return RangeAggregation |
||
64 | */ |
||
65 | public function setKeyed($keyed) |
||
71 | |||
72 | /** |
||
73 | * Add range to aggregation. |
||
74 | * |
||
75 | * @param int|float|null $from |
||
76 | * @param int|float|null $to |
||
77 | * @param string $key |
||
78 | * |
||
79 | * @return RangeAggregation |
||
80 | */ |
||
81 | public function addRange($from = null, $to = null, $key = '') |
||
98 | |||
99 | /** |
||
100 | * Remove range from aggregation. Returns true on success. |
||
101 | * |
||
102 | * @param int|float|null $from |
||
103 | * @param int|float|null $to |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function removeRange($from, $to) |
||
119 | |||
120 | /** |
||
121 | * Removes range by key. |
||
122 | * |
||
123 | * @param string $key Range key. |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | public function removeRangeByKey($key) |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function getArray() |
||
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | public function getType() |
||
166 | } |
||
167 |