We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02b13ff commit 108e494Copy full SHA for 108e494
src/Aggregation/Term.php
@@ -24,22 +24,29 @@ class Term implements LeafAggregationInterface
24
*/
25
private $missing;
26
27
+ /**
28
+ * @var string
29
+ */
30
+ private $key;
31
+
32
33
public function __construct(
34
string $field
35
, int $size = 5
36
, int $missing = NULL
37
+ , string $key = NULL
38
)
39
{
40
$this->field = $field;
41
$this->size = $size;
42
$this->missing = $missing;
43
+ $this->key = $key;
44
}
45
46
47
public function key() : string
48
- return $this->field;
49
+ return $this->key ?: $this->field;
50
51
52
@@ -55,7 +62,9 @@ public function toArray() : array
55
62
56
63
57
64
return [
58
- 'terms' => $array,
65
+ $this->key => [
66
+ 'terms' => $array,
67
+ ],
59
68
];
60
69
61
70
0 commit comments