修改es查询岗位名称或者类型

This commit is contained in:
sh
2026-07-14 12:30:11 +08:00
parent 1594f00305
commit 688b5f358a

View File

@@ -499,23 +499,41 @@ public class ESJobSearchImpl implements IESJobSearchService
); );
} }
}*/ }*/
//优化岗位名称查询,只有命中岗位名称或者分类就行
String titleStr = esJobSearch.getJobTitle(); String titleStr = esJobSearch.getJobTitle();
String cateStr = esJobSearch.getJobCategory(); String cateStr = esJobSearch.getJobCategory();
boolean hasTitle = !StringUtil.isEmptyOrNull(titleStr); boolean hasTitle = !StringUtil.isEmptyOrNull(titleStr);
boolean hasCate = !StringUtil.isEmptyOrNull(cateStr); boolean hasCate = !StringUtil.isEmptyOrNull(cateStr);
if (hasTitle || hasCate) { if (hasTitle || hasCate) {
wrapper.and(sub -> { wrapper.and(sub -> {
if (hasTitle) { if (hasTitle) {
String[] words = titleStr.split(","); String[] words = titleStr.split(",");
for (String w : words) { for (String w : words) {
if (!StringUtil.isEmptyOrNull(w)) { String word = w.trim();
sub.or().match(ESJobDocument::getJobTitle, w, 5.0f); if (StringUtil.isEmptyOrNull(word)) {
continue;
} }
sub.or(inner -> inner
.match(ESJobDocument::getJobTitle, word, 5.0f)
.or()
.match(ESJobDocument::getJobCategory, word, 5.0f)
);
} }
} }
if (hasCate) { if (hasCate) {
sub.or().eq(ESJobDocument::getJobCategory, cateStr); String[] words = cateStr.split(",");
for (String w : words) {
String word = w.trim();
if (StringUtil.isEmptyOrNull(word)) {
continue;
}
sub.or(inner -> inner
.match(ESJobDocument::getJobTitle, word, 5.0f)
.or()
.match(ESJobDocument::getJobCategory, word, 5.0f)
);
}
} }
}); });
} }