diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java index 0e977a4..4dfa8f1 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java @@ -491,12 +491,31 @@ public class ESJobSearchImpl implements IESJobSearchService private LambdaEsQueryWrapper getWrapper(ESJobSearch esJobSearch,List jobIds){ LambdaEsQueryWrapper wrapper = new LambdaEsQueryWrapper<>(); - if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ + /*if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ for (String keyWord:esJobSearch.getJobTitle().split(",")) { wrapper.or(a -> a.match(ESJobDocument::getJobTitle, keyWord, 5.0f) ); } - + }*/ + //优化岗位名称查询,只有命中岗位名称或者分类就行 + String titleStr = esJobSearch.getJobTitle(); + String cateStr = esJobSearch.getJobCategory(); + boolean hasTitle = !StringUtil.isEmptyOrNull(titleStr); + boolean hasCate = !StringUtil.isEmptyOrNull(cateStr); + if (hasTitle || hasCate) { + wrapper.and(sub -> { + if (hasTitle) { + String[] words = titleStr.split(","); + for (String w : words) { + if (!StringUtil.isEmptyOrNull(w)) { + sub.or().match(ESJobDocument::getJobTitle, w, 5.0f); + } + } + } + if (hasCate) { + sub.or().eq(ESJobDocument::getJobCategory, cateStr); + } + }); } if(esJobSearch.getLongitude()!=null){ @@ -520,13 +539,13 @@ public class ESJobSearchImpl implements IESJobSearchService List integers = StringUtil.convertStringToIntegerList(esJobSearch.getExperience()); wrapper.and(x->x.in(ESJobDocument::getExperience_int,integers));//精准查询 } - if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){ + /*if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){ //wrapper.and(x->x.eq(ESJobDocument::getJobCategory,esJobSearch.getJobCategory())); String targetValue = esJobSearch.getJobCategory(); wrapper.and(x -> x.like(ESJobDocument::getJobCategory, targetValue) .or() .like(ESJobDocument::getJobTitle, targetValue)); - } + }*/ if(!StringUtil.isEmptyOrNull(esJobSearch.getScale())){ //Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale()); //wrapper.and(x->x.le(ESJobDocument::getScale,maxValue));