diff --git a/src/main/java/org/elasticsearch/search/sort/SortParseElement.java b/src/main/java/org/elasticsearch/search/sort/SortParseElement.java index fa698a29831..dd9b7df06a9 100644 --- a/src/main/java/org/elasticsearch/search/sort/SortParseElement.java +++ b/src/main/java/org/elasticsearch/search/sort/SortParseElement.java @@ -122,6 +122,8 @@ public class SortParseElement implements SearchParseElement { reverse = SCORE_FIELD_NAME.equals(fieldName); } else if (direction.equals("desc")) { reverse = !SCORE_FIELD_NAME.equals(fieldName); + } else { + throw new ElasticSearchIllegalArgumentException("sort direction [" + fieldName + "] not supported"); } addSortField(context, sortFields, fieldName, reverse, ignoreUnmapped, missing, sortMode, nestedPath, nestedFilter); } else { @@ -144,14 +146,18 @@ public class SortParseElement implements SearchParseElement { missing = parser.textOrNull(); } else if ("ignore_unmapped".equals(innerJsonName) || "ignoreUnmapped".equals(innerJsonName)) { ignoreUnmapped = parser.booleanValue(); - } else if ("sort_mode".equals(innerJsonName) || "sortMode".equals(innerJsonName)) { + } else if ("sort_mode".equals(innerJsonName) || "sortMode".equals(innerJsonName) || "mode".equals(innerJsonName)) { sortMode = SortMode.fromString(parser.text()); } else if ("nested_path".equals(innerJsonName) || "nestedPath".equals(innerJsonName)) { nestedPath = parser.text(); + } else { + throw new ElasticSearchIllegalArgumentException("sort option [" + innerJsonName + "] not supported"); } } else if (token == XContentParser.Token.START_OBJECT) { if ("nested_filter".equals(innerJsonName) || "nestedFilter".equals(innerJsonName)) { nestedFilter = context.queryParserService().parseInnerFilter(parser); + } else { + throw new ElasticSearchIllegalArgumentException("sort option [" + innerJsonName + "] not supported"); } } }