-
Notifications
You must be signed in to change notification settings - Fork 733
/
Percentiles.php
103 lines (93 loc) · 2.35 KB
/
Percentiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace Elastica\Aggregation;
/**
* Class Percentiles.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
*/
class Percentiles extends AbstractSimpleAggregation
{
/**
* @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field = null)
{
parent::__construct($name);
if (!is_null($field)) {
$this->setField($field);
}
}
/**
* Set compression parameter.
*
* @param float $value
*
* @return Percentiles $this
*/
public function setCompression(float $value): Percentiles
{
$compression = ['compression' => $value];
return $this->setParam('tdigest', $compression);
}
/**
* Set hdr parameter.
*
* @param string $key
* @param float $value
*
* @return Percentiles $this
*/
public function setHdr(string $key, float $value): Percentiles
{
$compression = [$key => $value];
return $this->setParam('hdr', $compression);
}
/**
* the keyed flag is set to true which associates a unique string
* key with each bucket and returns the ranges as a hash
* rather than an array.
*
* @param bool $keyed
*
* @return Percentiles $this
*/
public function setKeyed(bool $keyed = true): Percentiles
{
return $this->setParam('keyed', $keyed);
}
/**
* Set which percents must be returned.
*
* @param float[] $percents
*
* @return Percentiles $this
*/
public function setPercents(array $percents): Percentiles
{
return $this->setParam('percents', $percents);
}
/**
* Add yet another percent to result.
*
* @param float $percent
*
* @return Percentiles $this
*/
public function addPercent(float $percent): Percentiles
{
return $this->addParam('percents', $percent);
}
/**
* Defines how documents that are missing a value should
* be treated.
*
* @param float $missing
*
* @return Percentiles
*/
public function setMissing(float $missing): Percentiles
{
return $this->setParam('missing', $missing);
}
}