修改es查询岗位名称或者类型
This commit is contained in:
@@ -499,23 +499,41 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
);
|
||||
}
|
||||
}*/
|
||||
//优化岗位名称查询,只有命中岗位名称或者分类就行
|
||||
|
||||
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);
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user