1 | <?php namespace Nord\Lumen\Elasticsearch\Search\Sort; |
||
2 | |||
3 | /** |
||
4 | * Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per |
||
5 | * field level, with special field name for _score to sort by score, and _doc to sort by index order. |
||
6 | * |
||
7 | * The order defaults to desc when sorting on the _score, and defaults to asc when sorting on anything else. |
||
8 | * |
||
9 | * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html |
||
10 | */ |
||
11 | class ScoreSort extends AbstractSort |
||
12 | { |
||
13 | /** |
||
14 | * @inheritdoc |
||
15 | */ |
||
16 | public function toArray() |
||
17 | { |
||
18 | $options = $this->applyOptions([]); |
||
19 | |||
20 | if (empty($options)) { |
||
21 | return '_score'; |
||
0 ignored issues
–
show
|
|||
22 | } else { |
||
23 | return ['_score' => $options]; |
||
24 | } |
||
25 | } |
||
26 | } |
||
27 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: