Skip to content

Commit

Permalink
Apply first sort option none was specificly defined and if query text…
Browse files Browse the repository at this point in the history
… wasn't provided, which means that only facets were used
  • Loading branch information
litvinovg committed Dec 14, 2023
1 parent e2fac29 commit ac80a0b
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,20 @@ private void addDefaultVitroFacets(VitroRequest vreq, SearchQuery query) {

private void addSortRules(VitroRequest vreq, SearchQuery query, Map<String, SortConfiguration> sortOptions) {
String sortType = getSortType(vreq);
if (sortOptions.isEmpty()) {
return;
}
if (!StringUtils.isBlank(sortType) && sortOptions.containsKey(sortType)) {
SortConfiguration conf = sortOptions.get(sortType);
query.addSortField(conf.getField(vreq.getLocale()), conf.getSortOrder());
conf.setSelected(true);

} else
//If text field is empty, then apply first sort option
if (StringUtils.isBlank(getQueryText(vreq))) {
SortConfiguration conf = sortOptions.get(0);
query.addSortField(conf.getField(vreq.getLocale()), conf.getSortOrder());
conf.setSelected(true);
}
}

Expand Down

0 comments on commit ac80a0b

Please sign in to comment.