mirror of https://github.com/apache/lucene.git
SOLR-4458: Sort directions (asc, desc) are now case insensitive
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1451765 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
88931a58a0
commit
05cc3a4706
|
@ -250,6 +250,9 @@ Other Changes
|
|||
|
||||
* SOLR-4511: Add new test for 'repeater' replication node. (Mark Miller)
|
||||
|
||||
* SOLR-4458: Sort directions (asc, desc) are now case insensitive
|
||||
(Shawn Heisey via hossman)
|
||||
|
||||
================== 4.1.0 ==================
|
||||
|
||||
Versions of Major Components
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -788,7 +789,7 @@ public class QueryParsing {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sort direction or null if current position does not inidcate a
|
||||
* Sort direction or null if current position does not indicate a
|
||||
* sort direction. (True is desc, False is asc).
|
||||
* Position is advanced to after the comma (or end) when result is non null
|
||||
*/
|
||||
|
@ -799,9 +800,10 @@ public class QueryParsing {
|
|||
Boolean top = null;
|
||||
|
||||
if (null != order) {
|
||||
if ("desc".equals(order) || "top".equals(order)) {
|
||||
final String orderLowerCase = order.toLowerCase(Locale.ROOT);
|
||||
if ("desc".equals(orderLowerCase) || "top".equals(orderLowerCase)) {
|
||||
top = true;
|
||||
} else if ("asc".equals(order) || "bottom".equals(order)) {
|
||||
} else if ("asc".equals(orderLowerCase) || "bottom".equals(orderLowerCase)) {
|
||||
top = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,17 +79,18 @@ public class QueryParsingTest extends SolrTestCaseJ4 {
|
|||
sort = QueryParsing.parseSort("score desc", req);
|
||||
assertNull("sort", sort);//only 1 thing in the list, no Sort specified
|
||||
|
||||
sort = QueryParsing.parseSort("score asc", req);
|
||||
// SOLR-4458 - using different case variations of asc and desc
|
||||
sort = QueryParsing.parseSort("score aSc", req);
|
||||
SortField[] flds = sort.getSort();
|
||||
assertEquals(flds[0].getType(), SortField.Type.SCORE);
|
||||
assertTrue(flds[0].getReverse());
|
||||
|
||||
sort = QueryParsing.parseSort("weight desc", req);
|
||||
sort = QueryParsing.parseSort("weight dEsC", req);
|
||||
flds = sort.getSort();
|
||||
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
|
||||
assertEquals(flds[0].getField(), "weight");
|
||||
assertEquals(flds[0].getReverse(), true);
|
||||
sort = QueryParsing.parseSort("weight desc,bday asc", req);
|
||||
sort = QueryParsing.parseSort("weight desc,bday ASC", req);
|
||||
flds = sort.getSort();
|
||||
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
|
||||
assertEquals(flds[0].getField(), "weight");
|
||||
|
@ -116,7 +117,7 @@ public class QueryParsingTest extends SolrTestCaseJ4 {
|
|||
assertEquals(flds[1].getReverse(), false);
|
||||
|
||||
//test weird spacing
|
||||
sort = QueryParsing.parseSort("weight desc, bday asc", req);
|
||||
sort = QueryParsing.parseSort("weight DESC, bday asc", req);
|
||||
flds = sort.getSort();
|
||||
assertEquals(flds[0].getType(), SortField.Type.FLOAT);
|
||||
assertEquals(flds[0].getField(), "weight");
|
||||
|
|
Loading…
Reference in New Issue