Authored by 胡古飞

搜索支持按真上新时间排序

... ... @@ -34,9 +34,14 @@ public class SearchSortHelper {
orderValues.add("id:desc");
orderValues.add("id:asc");
// 假上新时间
orderValues.add("shelve_time:desc");
orderValues.add("shelve_time:asc");
// 真上新时间
orderValues.add("first_shelve_time:desc");
orderValues.add("first_shelve_time:asc");
orderValues.add("sales_price:asc");
orderValues.add("sales_price:desc");
... ... @@ -54,7 +59,7 @@ public class SearchSortHelper {
orderValues.add("discount_score:desc");
orderValues.add("discount_score:asc");
orderValues.add("pools.id:desc");
orderValues.add("pools.id:asc");
... ... @@ -91,15 +96,15 @@ public class SearchSortHelper {
}
return realOrder.toString().replaceFirst(",", "");
}
public String dealSortField(String sortField){
public String dealSortField(String sortField) {
String[] sortParts = sortField.split(":");
String realSortField = sortParts[0];
if (realSortField.contains("activities")) {
// do nothing
}else if (realSortField.contains("pools")) {
} else if (realSortField.contains("pools")) {
// do nothing
}else if (realSortField.equals("discount")) {
} else if (realSortField.equals("discount")) {
realSortField = "promotionDiscount";
} else {
realSortField = CharUtils.underlineToCamelhump(realSortField);
... ... @@ -192,7 +197,7 @@ public class SearchSortHelper {
activitySort.setNestedFilter(activitiesTermsBuilder);
}
sortBuilders.add(activitySort);
} else if(fieldName.contains("pools")){
} else if (fieldName.contains("pools")) {
BoolQueryBuilder poolsTermsBuilder = searchCommonHelper.getPoolIdTermsBuilder(paramMap);
String flag = sortOrder.toString().equals("desc") ? "_last" : "_first";
FieldSortBuilder poolsIdSort = SortBuilders.fieldSort(fieldName).order(sortOrder).setNestedPath("pools").missing(flag);
... ... @@ -200,7 +205,7 @@ public class SearchSortHelper {
poolsIdSort.setNestedFilter(poolsTermsBuilder);
}
sortBuilders.add(poolsIdSort);
}else {
} else {
this.addSortBuildSorts(sortBuilders, filteredFieldNames, fieldName, sortOrder);
}
}
... ...