From b074ae45a5a662a3107c4de9e78a02f57bb88534 Mon Sep 17 00:00:00 2001 From: sh Date: Thu, 18 Jun 2026 16:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96es=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/service/impl/ESJobSearchImpl.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) 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));