support also mode in search sorting, and fail on illegal parameters
This commit is contained in:
parent
55ceb01c44
commit
5ed9fb2c54
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue