Skip to content

Commit 8fc648d

Browse files
committed
Добавил возможность указания конкретных полей поиска
1 parent bf7a735 commit 8fc648d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Aggregating/Metrics/TopHitsAggregation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class TopHitsAggregation implements Aggregation
1212
public function __construct(
1313
private string $name,
1414
private ?int $size = null,
15-
protected ?SortCollection $sort = null,
15+
private array $source = [],
16+
private ?SortCollection $sort = null,
1617
) {
1718
Assert::stringNotEmpty(trim($name));
1819
Assert::nullOrGreaterThan($this->size, 0);
@@ -39,6 +40,9 @@ public function toDSL(): array
3940
if ($this->sort) {
4041
$body['sort'] = $this->sort->toDSL();
4142
}
43+
if (!empty($this->source)) {
44+
$body['_source'] = $this->source;
45+
}
4246

4347
return [
4448
$this->name => [

0 commit comments

Comments
 (0)