API Change: search sort

This commit is contained in:
kimchy 2010-04-09 14:42:37 +03:00
parent 3a59397306
commit 7c93c1915f
1 changed files with 36 additions and 18 deletions

View File

@ -85,6 +85,23 @@ public class SortParseElement implements SearchParseElement {
boolean reverse = false; boolean reverse = false;
String innerJsonName = null; String innerJsonName = null;
int type = -1; int type = -1;
token = jp.nextToken();
if (token == JsonToken.VALUE_STRING) {
String direction = jp.getText();
if (direction.equals("asc")) {
if ("score".equals(fieldName)) {
reverse = true;
} else {
reverse = false;
}
} else if (direction.equals("desc")) {
if ("score".equals(fieldName)) {
reverse = false;
} else {
reverse = true;
}
}
} else {
while ((token = jp.nextToken()) != JsonToken.END_OBJECT) { while ((token = jp.nextToken()) != JsonToken.END_OBJECT) {
if (token == JsonToken.FIELD_NAME) { if (token == JsonToken.FIELD_NAME) {
innerJsonName = jp.getCurrentName(); innerJsonName = jp.getCurrentName();
@ -107,6 +124,7 @@ public class SortParseElement implements SearchParseElement {
} }
} }
} }
}
addSortField(context, sortFields, fieldName, reverse, type); addSortField(context, sortFields, fieldName, reverse, type);
} }
} }