Skip to content

Commit bca5696

Browse files
authored
Merge pull request #83 from fedorf4/v8-add-multiple-script-sorts
V8 add multiple script sorts
2 parents f67733c + e70e63a commit bca5696

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Search/Sorting/Sort.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function toDSL(): array
6565

6666
$details['order'] = $this->order;
6767

68-
return [$this->field => $details];
68+
return [$this->script !== null ? '_script' : $this->field => $details];
6969
}
7070

7171
public function __toString(): string

src/Search/Sorting/SortBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function sortBy(string $field, string $order = SortOrder::ASC, ?string $m
4949
public function sortByScript(Script $script, string $type = ScriptSortType::NUMBER, string $order = SortOrder::ASC): static
5050
{
5151
$sort = new Sort(
52-
field: '_script',
52+
field: '_script' . md5(json_encode($script->toDSL())),
5353
order: $order,
5454
type: $type,
5555
script: $script,

0 commit comments

Comments
 (0)