|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Elastica\Aggregation; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class GeotileGrid. |
|
7
|
|
|
* |
|
8
|
|
|
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html |
|
9
|
|
|
*/ |
|
10
|
|
|
class GeotileGrid extends AbstractAggregation |
|
11
|
|
|
{ |
|
12
|
|
|
public const DEFAULT_PRECISION_VALUE = 5; |
|
13
|
|
|
public const DEFAULT_SIZE_VALUE = 10000; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @param string $name the name of this aggregation |
|
17
|
|
|
* @param string $field the field on which to perform this aggregation |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct(string $name, string $field) |
|
20
|
|
|
{ |
|
21
|
|
|
parent::__construct($name); |
|
22
|
|
|
$this->setField($field); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Set the field for this aggregation. |
|
27
|
|
|
* |
|
28
|
|
|
* @param string $field the name of the document field on which to perform this aggregation |
|
29
|
|
|
* |
|
30
|
|
|
* @return $this |
|
31
|
|
|
*/ |
|
32
|
|
|
public function setField(string $field): self |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->setParam('field', $field); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Set the precision for this aggregation. |
|
39
|
|
|
* |
|
40
|
|
|
* @param int $precision an integer between 1 and 12, inclusive. Defaults to 5. |
|
41
|
|
|
* |
|
42
|
|
|
* @return $this |
|
43
|
|
|
*/ |
|
44
|
|
|
public function setPrecision(int $precision): self |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->setParam('precision', $precision); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Set the maximum number of buckets to return. |
|
51
|
|
|
* |
|
52
|
|
|
* @param int $size defaults to 10,000 |
|
53
|
|
|
* |
|
54
|
|
|
* @return $this |
|
55
|
|
|
*/ |
|
56
|
|
|
public function setSize(int $size): self |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->setParam('size', $size); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Set the number of results returned from each shard. |
|
63
|
|
|
* |
|
64
|
|
|
* @return $this |
|
65
|
|
|
*/ |
|
66
|
|
|
public function setShardSize(int $shardSize): self |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->setParam('shard_size', $shardSize); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|