Completed
Push — master ( 8a6a3b...86b2ed )
by Nicolas
03:28
created

Aggregation   A

Complexity

Total Complexity 34

Size/Duplication

Total Lines 491
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 31

Importance

Changes 0
Metric Value
wmc 34
lcom 0
cbo 31
dl 0
loc 491
rs 9.68
c 0
b 0
f 0

34 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A min() 0 4 1
A max() 0 4 1
A sum() 0 4 1
A sum_bucket() 0 4 1
A avg() 0 4 1
A avg_bucket() 0 4 1
A stats() 0 4 1
A extended_stats() 0 4 1
A value_count() 0 4 1
A percentiles() 0 4 1
A percentile_ranks() 0 4 1
A cardinality() 0 4 1
A geo_bounds() 0 4 1
A top_hits() 0 4 1
A scripted_metric() 0 4 1
A global_agg() 0 4 1
A filter() 0 4 1
A filters() 0 4 1
A missing() 0 4 1
A nested() 0 4 1
A reverse_nested() 0 4 1
A children() 0 4 1
A terms() 0 4 1
A significant_terms() 0 4 1
A range() 0 4 1
A date_range() 0 4 1
A ipv4_range() 0 4 1
A histogram() 0 4 1
A date_histogram() 0 4 1
A geo_distance() 0 4 1
A geohash_grid() 0 4 1
A bucket_script() 0 4 1
A serial_diff() 0 4 1
1
<?php
2
namespace Elastica\QueryBuilder\DSL;
3
4
use Elastica\Aggregation\Avg;
5
use Elastica\Aggregation\AvgBucket;
6
use Elastica\Aggregation\BucketScript;
7
use Elastica\Aggregation\Cardinality;
8
use Elastica\Aggregation\DateHistogram;
9
use Elastica\Aggregation\DateRange;
10
use Elastica\Aggregation\ExtendedStats;
11
use Elastica\Aggregation\Filter as FilterAggregation;
12
use Elastica\Aggregation\Filters;
13
use Elastica\Aggregation\GeoDistance;
14
use Elastica\Aggregation\GeohashGrid;
15
use Elastica\Aggregation\GlobalAggregation;
16
use Elastica\Aggregation\Histogram;
17
use Elastica\Aggregation\IpRange;
18
use Elastica\Aggregation\Max;
19
use Elastica\Aggregation\Min;
20
use Elastica\Aggregation\Missing;
21
use Elastica\Aggregation\Nested;
22
use Elastica\Aggregation\Percentiles;
23
use Elastica\Aggregation\Range;
24
use Elastica\Aggregation\ReverseNested;
25
use Elastica\Aggregation\ScriptedMetric;
26
use Elastica\Aggregation\SerialDiff;
27
use Elastica\Aggregation\SignificantTerms;
28
use Elastica\Aggregation\Stats;
29
use Elastica\Aggregation\Sum;
30
use Elastica\Aggregation\SumBucket;
31
use Elastica\Aggregation\Terms;
32
use Elastica\Aggregation\TopHits;
33
use Elastica\Aggregation\ValueCount;
34
use Elastica\Exception\NotImplementedException;
35
use Elastica\Query\AbstractQuery;
36
use Elastica\QueryBuilder\DSL;
37
38
/**
39
 * elasticsearch aggregation DSL.
40
 *
41
 * @author Manuel Andreo Garcia <[email protected]>
42
 *
43
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
44
 */
45
class Aggregation implements DSL
46
{
47
    /**
48
     * must return type for QueryBuilder usage.
49
     *
50
     * @return string
51
     */
52
    public function getType()
53
    {
54
        return DSL::TYPE_AGGREGATION;
55
    }
56
57
    /**
58
     * min aggregation.
59
     *
60
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
61
     *
62
     * @param string $name
63
     *
64
     * @return Min
65
     */
66
    public function min($name)
67
    {
68
        return new Min($name);
69
    }
70
71
    /**
72
     * max aggregation.
73
     *
74
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
75
     *
76
     * @param string $name
77
     *
78
     * @return Max
79
     */
80
    public function max($name)
81
    {
82
        return new Max($name);
83
    }
84
85
    /**
86
     * sum aggregation.
87
     *
88
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
89
     *
90
     * @param string $name
91
     *
92
     * @return Sum
93
     */
94
    public function sum($name)
95
    {
96
        return new Sum($name);
97
    }
98
99
    /**
100
     * sum bucket aggregation.
101
     *
102
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html
103
     *
104
     * @param string      $name
105
     * @param string|null $bucketsPath
106
     *
107
     * @return SumBucket
108
     */
109
    public function sum_bucket($name, $bucketsPath = null)
110
    {
111
        return new SumBucket($name, $bucketsPath);
112
    }
113
114
    /**
115
     * avg aggregation.
116
     *
117
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
118
     *
119
     * @param string $name
120
     *
121
     * @return Avg
122
     */
123
    public function avg($name)
124
    {
125
        return new Avg($name);
126
    }
127
128
    /**
129
     * avg bucket aggregation.
130
     *
131
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html
132
     *
133
     * @param string      $name
134
     * @param string|null $bucketsPath
135
     *
136
     * @return AvgBucket
137
     */
138
    public function avg_bucket($name, $bucketsPath = null)
139
    {
140
        return new AvgBucket($name, $bucketsPath);
141
    }
142
143
    /**
144
     * stats aggregation.
145
     *
146
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
147
     *
148
     * @param string $name
149
     *
150
     * @return Stats
151
     */
152
    public function stats($name)
153
    {
154
        return new Stats($name);
155
    }
156
157
    /**
158
     * extended stats aggregation.
159
     *
160
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
161
     *
162
     * @param string $name
163
     *
164
     * @return ExtendedStats
165
     */
166
    public function extended_stats($name)
167
    {
168
        return new ExtendedStats($name);
169
    }
170
171
    /**
172
     * value count aggregation.
173
     *
174
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
175
     *
176
     * @param string $name
177
     * @param string $field
178
     *
179
     * @return ValueCount
180
     */
181
    public function value_count($name, $field)
182
    {
183
        return new ValueCount($name, $field);
184
    }
185
186
    /**
187
     * percentiles aggregation.
188
     *
189
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
190
     *
191
     * @param string $name  the name of this aggregation
192
     * @param string $field the field on which to perform this aggregation
193
     *
194
     * @return Percentiles
195
     */
196
    public function percentiles($name, $field = null)
197
    {
198
        return new Percentiles($name, $field);
199
    }
200
201
    /**
202
     * percentile ranks aggregation.
203
     *
204
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html
205
     *
206
     * @param string $name
207
     */
208
    public function percentile_ranks($name)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
209
    {
210
        throw new NotImplementedException();
211
    }
212
213
    /**
214
     * cardinality aggregation.
215
     *
216
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
217
     *
218
     * @param string $name
219
     *
220
     * @return Cardinality
221
     */
222
    public function cardinality($name)
223
    {
224
        return new Cardinality($name);
225
    }
226
227
    /**
228
     * geo bounds aggregation.
229
     *
230
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html
231
     *
232
     * @param string $name
233
     */
234
    public function geo_bounds($name)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
235
    {
236
        throw new NotImplementedException();
237
    }
238
239
    /**
240
     * top hits aggregation.
241
     *
242
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
243
     *
244
     * @param string $name
245
     *
246
     * @return TopHits
247
     */
248
    public function top_hits($name)
249
    {
250
        return new TopHits($name);
251
    }
252
253
    /**
254
     * scripted metric aggregation.
255
     *
256
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html
257
     *
258
     * @param string      $name
259
     * @param string|null $initScript
260
     * @param string|null $mapScript
261
     * @param string|null $combineScript
262
     * @param string|null $reduceScript
263
     *
264
     * @return ScriptedMetric
265
     */
266
    public function scripted_metric($name, $initScript = null, $mapScript = null, $combineScript = null, $reduceScript = null)
267
    {
268
        return new ScriptedMetric($name, $initScript, $mapScript, $combineScript, $reduceScript);
269
    }
270
271
    /**
272
     * global aggregation.
273
     *
274
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
275
     *
276
     * @param string $name
277
     *
278
     * @return GlobalAggregation
279
     */
280
    public function global_agg($name)
281
    {
282
        return new GlobalAggregation($name);
283
    }
284
285
    /**
286
     * filter aggregation.
287
     *
288
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
289
     *
290
     * @param string        $name
291
     * @param AbstractQuery $filter
292
     *
293
     * @return FilterAggregation
294
     */
295
    public function filter($name, AbstractQuery $filter = null)
296
    {
297
        return new FilterAggregation($name, $filter);
298
    }
299
300
    /**
301
     * filters aggregation.
302
     *
303
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
304
     *
305
     * @param string $name
306
     *
307
     * @return Filters
308
     */
309
    public function filters($name)
310
    {
311
        return new Filters($name);
312
    }
313
314
    /**
315
     * missing aggregation.
316
     *
317
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
318
     *
319
     * @param string $name
320
     * @param string $field
321
     *
322
     * @return Missing
323
     */
324
    public function missing($name, $field)
325
    {
326
        return new Missing($name, $field);
327
    }
328
329
    /**
330
     * nested aggregation.
331
     *
332
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
333
     *
334
     * @param string $name
335
     * @param string $path the nested path for this aggregation
336
     *
337
     * @return Nested
338
     */
339
    public function nested($name, $path)
340
    {
341
        return new Nested($name, $path);
342
    }
343
344
    /**
345
     * reverse nested aggregation.
346
     *
347
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
348
     *
349
     * @param string $name The name of this aggregation
350
     * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document.
351
     *
352
     * @return ReverseNested
353
     */
354
    public function reverse_nested($name, $path = null)
0 ignored issues
show
Unused Code introduced by
The parameter $path is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
355
    {
356
        return new ReverseNested($name);
357
    }
358
359
    /**
360
     * children aggregation.
361
     *
362
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html
363
     *
364
     * @param string $name
365
     */
366
    public function children($name)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
367
    {
368
        throw new NotImplementedException();
369
    }
370
371
    /**
372
     * terms aggregation.
373
     *
374
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
375
     *
376
     * @param string $name
377
     *
378
     * @return Terms
379
     */
380
    public function terms($name)
381
    {
382
        return new Terms($name);
383
    }
384
385
    /**
386
     * significant terms aggregation.
387
     *
388
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
389
     *
390
     * @param string $name
391
     *
392
     * @return SignificantTerms
393
     */
394
    public function significant_terms($name)
395
    {
396
        return new SignificantTerms($name);
397
    }
398
399
    /**
400
     * range aggregation.
401
     *
402
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
403
     *
404
     * @param string $name
405
     *
406
     * @return Range
407
     */
408
    public function range($name)
409
    {
410
        return new Range($name);
411
    }
412
413
    /**
414
     * date range aggregation.
415
     *
416
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
417
     *
418
     * @param string $name
419
     *
420
     * @return DateRange
421
     */
422
    public function date_range($name)
423
    {
424
        return new DateRange($name);
425
    }
426
427
    /**
428
     * ipv4 range aggregation.
429
     *
430
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html
431
     *
432
     * @param string $name
433
     * @param string $field
434
     *
435
     * @return IpRange
436
     */
437
    public function ipv4_range($name, $field)
438
    {
439
        return new IpRange($name, $field);
440
    }
441
442
    /**
443
     * histogram aggregation.
444
     *
445
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
446
     *
447
     * @param string $name     the name of this aggregation
448
     * @param string $field    the name of the field on which to perform the aggregation
449
     * @param int    $interval the interval by which documents will be bucketed
450
     *
451
     * @return Histogram
452
     */
453
    public function histogram($name, $field, $interval)
454
    {
455
        return new Histogram($name, $field, $interval);
456
    }
457
458
    /**
459
     * date histogram aggregation.
460
     *
461
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
462
     *
463
     * @param string $name     the name of this aggregation
464
     * @param string $field    the name of the field on which to perform the aggregation
465
     * @param int    $interval the interval by which documents will be bucketed
466
     *
467
     * @return DateHistogram
468
     */
469
    public function date_histogram($name, $field, $interval)
470
    {
471
        return new DateHistogram($name, $field, $interval);
472
    }
473
474
    /**
475
     * geo distance aggregation.
476
     *
477
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
478
     *
479
     * @param string       $name   the name if this aggregation
480
     * @param string       $field  the field on which to perform this aggregation
481
     * @param string|array $origin the point from which distances will be calculated
482
     *
483
     * @return GeoDistance
484
     */
485
    public function geo_distance($name, $field, $origin)
486
    {
487
        return new GeoDistance($name, $field, $origin);
488
    }
489
490
    /**
491
     * geohash grid aggregation.
492
     *
493
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
494
     *
495
     * @param string $name  the name of this aggregation
496
     * @param string $field the field on which to perform this aggregation
497
     *
498
     * @return GeohashGrid
499
     */
500
    public function geohash_grid($name, $field)
501
    {
502
        return new GeohashGrid($name, $field);
503
    }
504
505
    /**
506
     * bucket script aggregation.
507
     *
508
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html
509
     *
510
     * @param string      $name
511
     * @param array|null  $bucketsPath
512
     * @param string|null $script
513
     *
514
     * @return BucketScript
515
     */
516
    public function bucket_script($name, $bucketsPath = null, $script = null)
517
    {
518
        return new BucketScript($name, $bucketsPath, $script);
519
    }
520
521
    /**
522
     * serial diff aggregation.
523
     *
524
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html
525
     *
526
     * @param string      $name
527
     * @param string|null $bucketsPath
528
     *
529
     * @return SerialDiff
530
     */
531
    public function serial_diff($name, $bucketsPath = null)
532
    {
533
        return new SerialDiff($name, $bucketsPath);
534
    }
535
}
536