add desc/asc to querystring sort option

This commit is contained in:
kimchy 2010-04-12 03:08:36 +03:00
parent ab5378ad28
commit a79dae696a
1 changed files with 7 additions and 1 deletions

View File

@ -195,7 +195,13 @@ public class RestSearchAction extends BaseRestHandler {
if (delimiter != -1) {
String sortField = sort.substring(0, delimiter);
String reverse = sort.substring(delimiter + 1);
searchSourceBuilder.sort(sortField, reverse.equals("reverse"));
if ("asc".equals(reverse)) {
searchSourceBuilder.sort(sortField, SearchSourceBuilder.Order.ASC);
} else if ("desc".equals(reverse)) {
searchSourceBuilder.sort(sortField, SearchSourceBuilder.Order.DESC);
} else {
searchSourceBuilder.sort(sortField, reverse.equals("reverse"));
}
} else {
searchSourceBuilder.sort(sort);
}