Skip to content

Commit a158aa0

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

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Search/Sorting/Sort.php

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

53-
if ($this->script !== null) {
54-
$this->field = '_script';
55-
$details['script'] = $this->script->toDSL();
56-
}
57-
5853
if (!$details) {
5954
return [$this->field => $this->order];
6055
}
6156

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

59+
if ($this->script !== null) {
60+
$details['script'] = $this->script->toDSL();
61+
62+
return ['_script' => $details];
63+
}
64+
6465
return [$this->field => $details];
6566
}
6667

0 commit comments

Comments
 (0)