fix use comma-separated sort value
@@ -584,11 +584,13 @@ public class QueryHelper {
context.addHighlightedQuery(text);
return buildDefaultQueryBuilder((f, b) -> buildMatchPhraseQuery(f, text).boost(b * boost));
} else if ("sort".equals(field)) {
- final String[] values = text.split("\\.");
+ split(text, ",").of(
+ stream -> stream.filter(StringUtil::isNotBlank).forEach(
+ t -> {
+ final String[] values = t.split("\\.");
if (values.length > 2) {
- throw new InvalidQueryException(
- messages -> messages.addErrorsInvalidQuerySortValue(UserMessages.GLOBAL_PROPERTY_KEY, text), "Invalid sort field: "
- + termQuery);
+ throw new InvalidQueryException(messages -> messages.addErrorsInvalidQuerySortValue(
+ UserMessages.GLOBAL_PROPERTY_KEY, text), "Invalid sort field: " + termQuery);
}
final String sortField = values[0];
if (!isSortField(sortField)) {
@@ -606,6 +608,7 @@ public class QueryHelper {
sortOrder = SortOrder.ASC;
}
context.addSorts(createFieldSortBuilder(sortField, sortOrder));
+ }));
return null;
} else if (INURL_FIELD.equals(field) || fessConfig.getIndexFieldUrl().equals(context.getDefaultField())) {
return QueryBuilders.wildcardQuery(fessConfig.getIndexFieldUrl(), "*" + text + "*").boost(boost);
