From a79dae696a661e2ce91168fca96f4f9641dea8fb Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 12 Apr 2010 03:08:36 +0300 Subject: [PATCH] add desc/asc to querystring sort option --- .../rest/action/search/RestSearchAction.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 37a83ba284a..699ae08d51b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -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); }