1.修改查询es排序问题,优先权重,在按照顺序

This commit is contained in:
chenshaohua
2026-06-18 13:22:17 +08:00
parent 3502be6478
commit 7d5ad10883

View File

@@ -594,6 +594,10 @@ public class ESJobSearchImpl implements IESJobSearchService
String formattedEndDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDateTime); String formattedEndDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDateTime);
wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate)); wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate));
} }
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
wrapper.trackScores();
wrapper.sortByScore(SortOrder.DESC);
if(Objects.nonNull(esJobSearch.getOrder())){ if(Objects.nonNull(esJobSearch.getOrder())){
wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last")); wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last"));
if(esJobSearch.getOrder()==1){ if(esJobSearch.getOrder()==1){