From cc64ef61f85a3b8816661829b5d1f73640620228 Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:22:56 +0300 Subject: [PATCH 1/6] Update SearchQuery.php --- src/Search/SearchQuery.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Search/SearchQuery.php b/src/Search/SearchQuery.php index 36eccd3..c5bfda8 100644 --- a/src/Search/SearchQuery.php +++ b/src/Search/SearchQuery.php @@ -198,10 +198,10 @@ protected function parseHits(array $response): Collection //endregion //region Customization - public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null): static + public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null, ?string $unmappedType = null): static { (new SortBuilder($this->sorts)) - ->sortBy($field, $order, $mode, $missingValues); + ->sortBy($field, $order, $mode, $missingValues, $unmappedType); return $this; } From d255714bb6ca8420a5513fa85bf6737647bcf90b Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:23:51 +0300 Subject: [PATCH 2/6] Update SortBuilder.php --- src/Search/Sorting/SortBuilder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Search/Sorting/SortBuilder.php b/src/Search/Sorting/SortBuilder.php index 0dfb850..3a4138b 100644 --- a/src/Search/Sorting/SortBuilder.php +++ b/src/Search/Sorting/SortBuilder.php @@ -28,7 +28,7 @@ public function __construct(SortCollection $sorts) $this->levels = new Collection(); } - public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null): static + public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null, ?string $unmappedType = null): static { $path = $this->absolutePath($field); @@ -37,7 +37,8 @@ public function sortBy(string $field, string $order = SortOrder::ASC, ?string $m strtolower($order), $mode === null ? $mode : strtolower($mode), $this->buildNested(), - $missingValues + $missingValues, + $unmappedType ); $this->sorts->add($sort); From fd6c94a235c9a9fdc2867dc08ca17b9e1aaf5bcc Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:24:17 +0300 Subject: [PATCH 3/6] Update Sort.php --- src/Search/Sorting/Sort.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Search/Sorting/Sort.php b/src/Search/Sorting/Sort.php index ed82f53..8a6ec4b 100644 --- a/src/Search/Sorting/Sort.php +++ b/src/Search/Sorting/Sort.php @@ -19,6 +19,7 @@ public function __construct( private ?string $missingValues = null, private ?string $type = null, private ?Script $script = null, + private ?string $unmappedType = null, ) { Assert::stringNotEmpty(trim($field)); Assert::oneOf($order, SortOrder::cases()); @@ -54,6 +55,10 @@ public function toDSL(): array $details['script'] = $this->script->toDSL(); } + if ($this->unmappedType !== null) { + $details['unmapped_type'] = $this->unmappedType; + } + if (!$details) { return [$this->field => $this->order]; } From a65f1fbe74d7e968d48444776e4247bcc6157a65 Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:37:17 +0300 Subject: [PATCH 4/6] Update SortableQuery.php --- src/Contracts/SortableQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contracts/SortableQuery.php b/src/Contracts/SortableQuery.php index 9009ce3..5379cc7 100644 --- a/src/Contracts/SortableQuery.php +++ b/src/Contracts/SortableQuery.php @@ -7,7 +7,7 @@ interface SortableQuery extends BoolQuery { - public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null): static; + public function sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null, ?string $unmappedType = null): static; public function minSortBy(string $field, string $order = SortOrder::ASC): static; From ba27708bae9232f38ada08b540891b6ddaec18b7 Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:37:44 +0300 Subject: [PATCH 5/6] Update SortBuilder.php --- src/Search/Sorting/SortBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Search/Sorting/SortBuilder.php b/src/Search/Sorting/SortBuilder.php index 3a4138b..a887efe 100644 --- a/src/Search/Sorting/SortBuilder.php +++ b/src/Search/Sorting/SortBuilder.php @@ -38,7 +38,7 @@ public function sortBy(string $field, string $order = SortOrder::ASC, ?string $m $mode === null ? $mode : strtolower($mode), $this->buildNested(), $missingValues, - $unmappedType + unmappedType: $unmappedType ); $this->sorts->add($sort); From cbc0894ff48029c6bbb578f6b6cc5537a2ff4db6 Mon Sep 17 00:00:00 2001 From: Fedor Fomichev <79131391+fedorf4@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:53:25 +0300 Subject: [PATCH 6/6] Update ExtendsSort.php --- src/Concerns/ExtendsSort.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Concerns/ExtendsSort.php b/src/Concerns/ExtendsSort.php index 7e4a921..b4fe865 100644 --- a/src/Concerns/ExtendsSort.php +++ b/src/Concerns/ExtendsSort.php @@ -9,7 +9,7 @@ /** * @psalm-require-implements \Ensi\LaravelElasticQuery\Contracts\SortableQuery * - * @method static sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null) + * @method static sortBy(string $field, string $order = SortOrder::ASC, ?string $mode = null, ?string $missingValues = null, ?string $unmappedType = null) */ trait ExtendsSort {