Skip to content

Commit

Permalink
Merge pull request #9 from JeremyDunn/sorting
Browse files Browse the repository at this point in the history
Adds support for sorting search results
  • Loading branch information
JeremyDunn authored Jun 28, 2018
2 parents 7c5ddd4 + d0078ed commit 3d327c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.5.0",
"tamayo/laravel-scout-elastic": "^2.0"
},
"autoload": {
Expand Down
7 changes: 7 additions & 0 deletions src/Engines/NestedElasticSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ protected function performSearch(Builder $query, array $options = [])
]);
}

if (!empty($query->orders)) {
$searchQuery['sort'] = [];
foreach ($query->orders as $order) {
$searchQuery['sort'][] = "{$order['column']}:{$order['direction']}";
}
}

return $this->elastic->search($searchQuery);
}

Expand Down

0 comments on commit 3d327c7

Please sign in to comment.