|
1
|
|
|
<?php |
|
2
|
|
|
namespace Triadev\Leopard\Business\Dsl\Aggregation; |
|
3
|
|
|
|
|
4
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\BucketScriptAggregation; |
|
5
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\BucketSelectorAggregation; |
|
6
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\CumulativeSumAggregation; |
|
7
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\DerivativeAggregation; |
|
8
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\ExtendedStatsBucketAggregation; |
|
9
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\PercentilesBucketAggregation; |
|
10
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\AvgBucketAggregation; |
|
11
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\MaxBucketAggregation; |
|
12
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\MinBucketAggregation; |
|
13
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\SerialDifferencingAggregation; |
|
14
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\StatsBucketAggregation; |
|
15
|
|
|
use ONGR\ElasticsearchDSL\Aggregation\Pipeline\SumBucketAggregation; |
|
16
|
|
|
|
|
17
|
|
|
class Pipeline extends Aggs |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Avg |
|
21
|
|
|
* |
|
22
|
|
|
* @param string $name |
|
23
|
|
|
* @param string $bucketsPath |
|
24
|
|
|
* @return Pipeline |
|
25
|
|
|
*/ |
|
26
|
1 |
|
public function avg(string $name, string $bucketsPath): Pipeline |
|
27
|
|
|
{ |
|
28
|
1 |
|
$this->addAggregation(new AvgBucketAggregation($name, $bucketsPath)); |
|
29
|
1 |
|
return $this; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Max |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $name |
|
36
|
|
|
* @param string $bucketsPath |
|
37
|
|
|
* @return Pipeline |
|
38
|
|
|
*/ |
|
39
|
1 |
|
public function max(string $name, string $bucketsPath): Pipeline |
|
40
|
|
|
{ |
|
41
|
1 |
|
$this->addAggregation(new MaxBucketAggregation($name, $bucketsPath)); |
|
42
|
1 |
|
return $this; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Min |
|
47
|
|
|
* |
|
48
|
|
|
* @param string $name |
|
49
|
|
|
* @param string $bucketsPath |
|
50
|
|
|
* @return Pipeline |
|
51
|
|
|
*/ |
|
52
|
1 |
|
public function min(string $name, string $bucketsPath): Pipeline |
|
53
|
|
|
{ |
|
54
|
1 |
|
$this->addAggregation(new MinBucketAggregation($name, $bucketsPath)); |
|
55
|
1 |
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Percentiles |
|
60
|
|
|
* |
|
61
|
|
|
* @param string $name |
|
62
|
|
|
* @param string $bucketsPath |
|
63
|
|
|
* @return Pipeline |
|
64
|
|
|
*/ |
|
65
|
1 |
|
public function percentiles(string $name, string $bucketsPath): Pipeline |
|
66
|
|
|
{ |
|
67
|
1 |
|
$this->addAggregation(new PercentilesBucketAggregation($name, $bucketsPath)); |
|
68
|
1 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Stats |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $name |
|
75
|
|
|
* @param string $bucketsPath |
|
76
|
|
|
* @return Pipeline |
|
77
|
|
|
*/ |
|
78
|
1 |
|
public function stats(string $name, string $bucketsPath): Pipeline |
|
79
|
|
|
{ |
|
80
|
1 |
|
$this->addAggregation(new StatsBucketAggregation($name, $bucketsPath)); |
|
81
|
1 |
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Sum |
|
86
|
|
|
* |
|
87
|
|
|
* @param string $name |
|
88
|
|
|
* @param string $bucketsPath |
|
89
|
|
|
* @return Pipeline |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function sum(string $name, string $bucketsPath): Pipeline |
|
92
|
|
|
{ |
|
93
|
1 |
|
$this->addAggregation(new SumBucketAggregation($name, $bucketsPath)); |
|
94
|
1 |
|
return $this; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Serial differencing |
|
99
|
|
|
* |
|
100
|
|
|
* @param string $name |
|
101
|
|
|
* @param string $bucketsPath |
|
102
|
|
|
* @return Pipeline |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function serialDifferencing(string $name, string $bucketsPath) : Pipeline |
|
105
|
|
|
{ |
|
106
|
1 |
|
$this->addAggregation(new SerialDifferencingAggregation($name, $bucketsPath)); |
|
107
|
1 |
|
return $this; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Extended stats |
|
112
|
|
|
* |
|
113
|
|
|
* @param string $name |
|
114
|
|
|
* @param string $bucketsPath |
|
115
|
|
|
* @return Pipeline |
|
116
|
|
|
*/ |
|
117
|
1 |
|
public function extendedStats(string $name, string $bucketsPath) : Pipeline |
|
118
|
|
|
{ |
|
119
|
1 |
|
$this->addAggregation(new ExtendedStatsBucketAggregation($name, $bucketsPath)); |
|
120
|
1 |
|
return $this; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Derivative |
|
125
|
|
|
* |
|
126
|
|
|
* @param string $name |
|
127
|
|
|
* @param string $bucketsPath |
|
128
|
|
|
* @return Pipeline |
|
129
|
|
|
*/ |
|
130
|
1 |
|
public function derivative(string $name, string $bucketsPath) : Pipeline |
|
131
|
|
|
{ |
|
132
|
1 |
|
$this->addAggregation(new DerivativeAggregation($name, $bucketsPath)); |
|
133
|
1 |
|
return $this; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Cumulative sum |
|
138
|
|
|
* |
|
139
|
|
|
* @param string $name |
|
140
|
|
|
* @param string $bucketsPath |
|
141
|
|
|
* @return Pipeline |
|
142
|
|
|
*/ |
|
143
|
1 |
|
public function cumulativeSum(string $name, string $bucketsPath) : Pipeline |
|
144
|
|
|
{ |
|
145
|
1 |
|
$this->addAggregation(new CumulativeSumAggregation($name, $bucketsPath)); |
|
146
|
1 |
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* Bucket selector |
|
151
|
|
|
* |
|
152
|
|
|
* @param string $name |
|
153
|
|
|
* @param string $bucketsPath |
|
154
|
|
|
* @param string $script |
|
155
|
|
|
* @return Pipeline |
|
156
|
|
|
*/ |
|
157
|
1 |
|
public function bucketSelector(string $name, string $bucketsPath, string $script) : Pipeline |
|
158
|
|
|
{ |
|
159
|
1 |
|
$this->addAggregation(new BucketSelectorAggregation($name, $bucketsPath, $script)); |
|
|
|
|
|
|
160
|
1 |
|
return $this; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Bucket |
|
165
|
|
|
* |
|
166
|
|
|
* @param string $name |
|
167
|
|
|
* @param string $bucketsPath |
|
168
|
|
|
* @param string $script |
|
169
|
|
|
* @return Pipeline |
|
170
|
|
|
*/ |
|
171
|
1 |
|
public function bucketScript(string $name, string $bucketsPath, string $script) : Pipeline |
|
172
|
|
|
{ |
|
173
|
1 |
|
$this->addAggregation(new BucketScriptAggregation($name, $bucketsPath, $script)); |
|
|
|
|
|
|
174
|
1 |
|
return $this; |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|