Skip to content

Commit e2be05a

Browse files
authored
Update Sort.php
1 parent a158aa0 commit e2be05a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Search/Sorting/Sort.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,17 @@ public function toDSL(): array
5050
$details['type'] = $this->type;
5151
}
5252

53+
if ($this->script !== null) {
54+
$details['script'] = $this->script->toDSL();
55+
}
56+
5357
if (!$details) {
5458
return [$this->field => $this->order];
5559
}
5660

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

59-
if ($this->script !== null) {
60-
$details['script'] = $this->script->toDSL();
61-
62-
return ['_script' => $details];
63-
}
64-
65-
return [$this->field => $details];
63+
return [$this->script !== null ? '_script' : $this->field => $details];
6664
}
6765

6866
public function __toString(): string

0 commit comments

Comments
 (0)