添加es查询是JobTitle或者JobCategory

This commit is contained in:
chenshaohua
2026-06-26 13:46:31 +08:00
parent 1bd611d569
commit a78703ede7

View File

@@ -500,18 +500,27 @@ public class ESJobSearchImpl implements IESJobSearchService
String cateStr = esJobSearch.getJobCategory();
if (!StringUtil.isEmptyOrNull(titleStr) || !StringUtil.isEmptyOrNull(cateStr)) {
wrapper.and(sub -> {
boolean first = true;
sub.or();
boolean hasPrev = false;
if (!StringUtil.isEmptyOrNull(titleStr)) {
String[] words = titleStr.split(",");
for (String w : words) {
if (!first) sub.or();
for (int i = 0; i < words.length; i++) {
String w = words[i];
sub.match(ESJobDocument::getJobTitle, w, 5.0f);
first = false;
if (i != words.length - 1) {
sub.or();
}
}
hasPrev = true;
sub.or();
sub.eq(ESJobDocument::getJobCategory, titleStr);
}
if (!StringUtil.isEmptyOrNull(cateStr)) {
if (!first) sub.or();
if (!StringUtil.isEmptyOrNull(cateStr) && !cateStr.equals(titleStr)) {
if (hasPrev) {
sub.or();
}
sub.match(ESJobDocument::getJobTitle, cateStr, 5.0f);
sub.or();
sub.eq(ESJobDocument::getJobCategory, cateStr);
}
});