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