From f99d4017890ef062bbe26d3d29ace2315731508c Mon Sep 17 00:00:00 2001 From: Olek Kaim Date: Mon, 11 Sep 2023 20:03:25 +0200 Subject: [PATCH] 1.11.0 --- src/Builder/Builder.php | 4 ++++ src/Client.php | 4 ++++ src/Dto/SearchHitDto.php | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Builder/Builder.php b/src/Builder/Builder.php index 4c10f03..a39544f 100644 --- a/src/Builder/Builder.php +++ b/src/Builder/Builder.php @@ -448,6 +448,10 @@ public function getNested(): array public function performSearchBody(): void { + if (isset($this->sort)) { + $this->body['sort'] = $this->sort; + } + if (isset($this->nested)) { foreach ($this->nested as $nested) { $this->body['query']['bool']['must'][] = $nested; diff --git a/src/Client.php b/src/Client.php index ec4e2ef..cc89e9e 100644 --- a/src/Client.php +++ b/src/Client.php @@ -283,6 +283,10 @@ public function count(string $index, array $data = []): int unset($data['aggs']); } + if (isset($data['sort'])) { + unset($data['sort']); + } + if (empty($data)) { $data = [ 'query' => [ diff --git a/src/Dto/SearchHitDto.php b/src/Dto/SearchHitDto.php index 8e56e2f..6b59949 100644 --- a/src/Dto/SearchHitDto.php +++ b/src/Dto/SearchHitDto.php @@ -10,7 +10,7 @@ class SearchHitDto implements ResponseDtoInterface, Arrayable public function __construct( private readonly string $index, private readonly string $id, - private readonly float $score, + private readonly ?float $score, private readonly array $source, ) { } @@ -25,7 +25,7 @@ public function getId(): string return $this->id; } - public function getScore(): float + public function getScore(): ?float { return $this->score; }