Skip to content

Commit

Permalink
Merge pull request #83 from fedorf4/v8-add-multiple-script-sorts
Browse files Browse the repository at this point in the history
V8 add multiple script sorts
  • Loading branch information
MsNatali authored Feb 7, 2025
2 parents f67733c + e70e63a commit bca5696
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Search/Sorting/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function toDSL(): array

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

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

public function __toString(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Search/Sorting/SortBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function sortBy(string $field, string $order = SortOrder::ASC, ?string $m
public function sortByScript(Script $script, string $type = ScriptSortType::NUMBER, string $order = SortOrder::ASC): static
{
$sort = new Sort(
field: '_script',
field: '_script' . md5(json_encode($script->toDSL())),
order: $order,
type: $type,
script: $script,
Expand Down

0 comments on commit bca5696

Please sign in to comment.