修改es分词查询
This commit is contained in:
@@ -316,7 +316,7 @@ public class CmsAppUserController extends BaseController
|
||||
try {
|
||||
Long userId=null;
|
||||
if(SecurityUtils.isLogin()){
|
||||
userId=SecurityUtils.getUserId();
|
||||
userId=RoleUtils.getSysAppuserId();
|
||||
}
|
||||
String templatePath="/data/downloadmodel/简历.docx";
|
||||
AppUser result=appUserService.selectAppUserByUserId(userId);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ruoyi.cms.domain.ik;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class JobSearchCondition {
|
||||
@@ -30,4 +29,9 @@ public class JobSearchCondition {
|
||||
private String educationText;
|
||||
/** 匹配到的工作经验原始文本(3-5年/应届毕业生...用于过滤岗位名称) */
|
||||
private String workExpText;
|
||||
|
||||
/**
|
||||
* 所属行政区划
|
||||
*/
|
||||
private String regionCode;
|
||||
}
|
||||
@@ -663,9 +663,15 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
// }
|
||||
// }
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getJobTitle())){
|
||||
wrapper.and(a->a.match(ESJobDocument::getJobTitle,jobQuery.getJobTitle(),5.0f)
|
||||
.or()
|
||||
.match(ESJobDocument::getDescription,jobQuery.getJobTitle(),1.0f));
|
||||
List<String> jobNameList = splitJobNames(jobQuery.getJobTitle());
|
||||
if(jobNameList != null && !jobNameList.isEmpty()){
|
||||
wrapper.and(mainBool -> mainBool.should(outer -> {
|
||||
for (String word : jobNameList) {
|
||||
outer.should(sub -> sub.match(ESJobDocument::getJobTitle, word, 5.0f)
|
||||
.or().match(ESJobDocument::getDescription, word, 1.0f));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(jobQuery.getEducation())){
|
||||
List<Integer> integers=StringUtil.convertStringToIntegerList(jobQuery.getEducation());
|
||||
@@ -967,4 +973,15 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
|
||||
private List<String> splitJobNames(String jobStr) {
|
||||
if (StringUtil.isEmptyOrNull(jobStr)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(jobStr.split(","))
|
||||
.map(String::trim)
|
||||
.map(s -> s.replace("/", " "))
|
||||
.filter(s -> !StringUtil.isEmptyOrNull(s))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.cms.util.ik;
|
||||
|
||||
import com.ruoyi.cms.domain.ik.JobSearchCondition;
|
||||
import com.ruoyi.cms.domain.ik.ParserDictDTO;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -34,6 +35,9 @@ public class TextConditionParserUtil {
|
||||
"(月薪|薪资|工资)\\s*(一|二|三|四|五|六|七|八|九|十)(千|万)"
|
||||
);
|
||||
|
||||
// 定义喀什地区固定编码常量
|
||||
private static final String KASHGAR_FULL_CODE = "653100000000";
|
||||
|
||||
//中文数字映射表
|
||||
private static Long getChineseNum(String numChar, String unit) {
|
||||
int num;
|
||||
@@ -103,8 +107,10 @@ public class TextConditionParserUtil {
|
||||
|
||||
// 5.拼接岗位名称,过滤已识别维度词汇
|
||||
List<String> matchJobList= extractStandardJobName(input, tokenList,dictDTO.getStandardJobSet(),dictDTO.getJobIndexMap());
|
||||
if (matchJobList != null && !matchJobList.isEmpty()) {
|
||||
condition.setJobTitle(String.join(",", matchJobList));
|
||||
//拆分带/的
|
||||
List<String> finalJobList = splitFilterDistinct(matchJobList,input);
|
||||
if (finalJobList != null && !finalJobList.isEmpty()) {
|
||||
condition.setJobTitle(String.join(",", finalJobList));
|
||||
} else {
|
||||
condition.setJobTitle(input);
|
||||
}
|
||||
@@ -114,14 +120,22 @@ public class TextConditionParserUtil {
|
||||
private static void extractAreaCode(String text, JobSearchCondition condition, Map<String, Integer> areaMap) {
|
||||
List<Map.Entry<String, Integer>> entryList = new ArrayList<>(areaMap.entrySet());
|
||||
entryList.sort((o1, o2) -> Integer.compare(o2.getKey().length(), o1.getKey().length()));
|
||||
|
||||
boolean hitCounty = false;
|
||||
for (Map.Entry<String, Integer> entry : entryList) {
|
||||
String areaName = entry.getKey();
|
||||
if (text.contains(areaName)) {
|
||||
condition.setAddress(areaName);
|
||||
condition.setJobLocationAreaCode(String.valueOf(entry.getValue()));
|
||||
hitCounty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hitCounty && text.contains("喀什地区")) {
|
||||
condition.setAddress("喀什地区");
|
||||
condition.setRegionCode(KASHGAR_FULL_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
private static void extractWorkExpCode(String text, JobSearchCondition condition, Map<String, Integer> expMap) {
|
||||
@@ -280,7 +294,7 @@ public class TextConditionParserUtil {
|
||||
List<String> jobList = new ArrayList<>(standardJobSet);
|
||||
// 长名称优先,优先匹配更长岗位,避免短词根优先命中
|
||||
jobList.sort((s1, s2) -> Integer.compare(s2.length(), s1.length()));
|
||||
final int MAX_MATCH_SIZE = 5;
|
||||
//final int MAX_MATCH_SIZE = 5;
|
||||
|
||||
for (String jobName : jobList) {
|
||||
if (text.contains(jobName)) {
|
||||
@@ -298,9 +312,9 @@ public class TextConditionParserUtil {
|
||||
for (String jobName : jobList) {
|
||||
if (jobName.contains(word)) {
|
||||
matchSet.add(jobName);
|
||||
if (matchSet.size() >= MAX_MATCH_SIZE) {
|
||||
return new ArrayList<>(matchSet);
|
||||
}
|
||||
// if (matchSet.size() >= MAX_MATCH_SIZE) {
|
||||
// return new ArrayList<>(matchSet);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,6 +326,32 @@ public class TextConditionParserUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分岗位斜杠、全局去重
|
||||
*/
|
||||
private static List<String> splitFilterDistinct(List<String> sourceList, String rawInput) {
|
||||
if (sourceList == null || sourceList.isEmpty() || StringUtil.isEmptyOrNull(rawInput)) {
|
||||
return null;
|
||||
}
|
||||
String cleanInput = rawInput.replace("/", "");
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String str : sourceList) {
|
||||
String[] arr = str.split("/");
|
||||
for (String seg : arr) {
|
||||
String trimSeg = seg.trim();
|
||||
if (StringUtil.isEmptyOrNull(trimSeg)) {
|
||||
continue;
|
||||
}
|
||||
// 过滤无关联片段
|
||||
if (rawInput.contains(trimSeg) || trimSeg.contains(cleanInput)) {
|
||||
set.add(trimSeg);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> res = new ArrayList<>(set);
|
||||
return res.isEmpty() ? null : res;
|
||||
}
|
||||
|
||||
private static boolean isFilterWord(String word, JobSearchCondition condition) {
|
||||
// 基础过滤词
|
||||
if (word.matches("\\d+") || new ArrayList<>(Arrays.asList(
|
||||
|
||||
@@ -68,6 +68,7 @@ public class EncryptConstants {
|
||||
"/app/user/list",
|
||||
"/app/appskill/list",
|
||||
"/cms/appskill/list",
|
||||
"/cms/employeeConfirm/list"
|
||||
"/cms/employeeConfirm/list",
|
||||
"/app/user/createResume"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user