修改排序问题
This commit is contained in:
@@ -576,17 +576,29 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(Objects.nonNull(esJobSearch.getIsPublish())){
|
||||
wrapper.and(x->x.eq(ESJobDocument::getIsPublish,esJobSearch.getIsPublish()));
|
||||
}
|
||||
// 全局固定:权重优先(必须写在最前面)
|
||||
wrapper.trackScores();
|
||||
wrapper.sortByScore(SortOrder.DESC);
|
||||
//0:推荐 1:最热 2:最新发布 3:最大薪资
|
||||
if(Objects.nonNull(esJobSearch.getOrder())){
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
if(esJobSearch.getOrder()==1){
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
switch (esJobSearch.getOrder()) {
|
||||
case 0: // 推荐:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
break;
|
||||
case 1: // 最热:权重 → 热度
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
wrapper.orderByDesc(ESJobDocument::getApplyNum);
|
||||
wrapper.orderByDesc(ESJobDocument::getView);
|
||||
break;
|
||||
case 2: // 最新发布:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
break;
|
||||
case 3: // 最大薪资:权重 → 最高薪资
|
||||
wrapper.orderByDesc(ESJobDocument::getMaxSalary);
|
||||
break;
|
||||
default: // 默认:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
if(esJobSearch.getOrder()==3){
|
||||
wrapper.orderByDesc(ESJobDocument::getMaxSalary);
|
||||
}
|
||||
}else{
|
||||
//默认按照发布时间倒叙
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
//企业用户排除es去除jobIds
|
||||
boolean isCompanyUser = StringUtil.IS_COMPANY_USER.equals(esJobSearch.getUserType());
|
||||
@@ -694,16 +706,29 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(Objects.nonNull(jobQuery.getIsPublish())){
|
||||
wrapper.and(x->x.eq(ESJobDocument::getIsPublish,jobQuery.getIsPublish()));
|
||||
}
|
||||
// 全局固定:权重优先(必须写在最前面)
|
||||
wrapper.trackScores();
|
||||
wrapper.sortByScore(SortOrder.DESC);
|
||||
//0:推荐 1:最热 2:最新发布 3:最大薪资
|
||||
if(Objects.nonNull(jobQuery.getOrder())){
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
if (jobQuery.getOrder()==1){
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
wrapper.orderByDesc(ESJobDocument::getApplyNum);
|
||||
wrapper.orderByDesc(ESJobDocument::getView);
|
||||
switch (jobQuery.getOrder()) {
|
||||
case 0: // 推荐:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
break;
|
||||
case 1: // 最热:权重 → 热度
|
||||
wrapper.orderByDesc(ESJobDocument::getIsHot);
|
||||
wrapper.orderByDesc(ESJobDocument::getApplyNum);
|
||||
wrapper.orderByDesc(ESJobDocument::getView);
|
||||
break;
|
||||
case 2: // 最新发布:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
break;
|
||||
case 3: // 最大薪资:权重 → 最高薪资
|
||||
wrapper.orderByDesc(ESJobDocument::getMaxSalary);
|
||||
break;
|
||||
default: // 默认:权重 → 最新发布
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
}else{
|
||||
//默认按照发布时间倒叙
|
||||
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
|
||||
}
|
||||
EsPageInfo<ESJobDocument> esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize);
|
||||
return esJobDocumentEsPageInfo;
|
||||
|
||||
Reference in New Issue
Block a user