Skip to content

Commit 8d313c9

Browse files
committed
Added TopHits aggregation
1 parent b6fe339 commit 8d313c9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Aggregation/TopHits.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\ElasticQuery\Aggregation;
4+
5+
class TopHits implements \Spameri\ElasticQuery\Aggregation\LeafAggregationInterface
6+
{
7+
8+
private int $size;
9+
10+
11+
public function __construct(
12+
int $size
13+
) {
14+
$this->size = $size;
15+
}
16+
17+
18+
public function key(): string
19+
{
20+
return 'top_hits_' . $this->size;
21+
}
22+
23+
24+
public function toArray(): array
25+
{
26+
return [
27+
'top_hits' => [
28+
'size' => $this->size,
29+
],
30+
];
31+
}
32+
33+
}

0 commit comments

Comments
 (0)