{sort: "field"} throws misleading errors

fixes #2835
This commit is contained in:
Shay Banon 2013-03-30 13:46:53 +01:00
parent 2e93329e23
commit 6a1cb8f61b
1 changed files with 5 additions and 1 deletions

View File

@ -81,8 +81,12 @@ public class SortParseElement implements SearchParseElement {
addSortField(context, sortFields, parser.text(), false, false, null, null, null, null);
}
}
} else {
} else if (token == XContentParser.Token.VALUE_STRING) {
addSortField(context, sortFields, parser.text(), false, false, null, null, null, null);
} else if (token == XContentParser.Token.START_OBJECT) {
addCompoundSortField(parser, context, sortFields);
} else {
throw new ElasticSearchIllegalArgumentException("malformed sort format, either start with array, object, or an actual string");
}
if (!sortFields.isEmpty()) {
// optimize if we just sort on score non reversed, we don't really need sorting