优化es查询
This commit is contained in:
@@ -491,12 +491,31 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
private LambdaEsQueryWrapper<ESJobDocument> getWrapper(ESJobSearch esJobSearch,List<Long> jobIds){
|
||||
|
||||
LambdaEsQueryWrapper<ESJobDocument> wrapper = new LambdaEsQueryWrapper<>();
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
/*if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){
|
||||
for (String keyWord:esJobSearch.getJobTitle().split(",")) {
|
||||
wrapper.or(a -> a.match(ESJobDocument::getJobTitle, keyWord, 5.0f)
|
||||
);
|
||||
}
|
||||
|
||||
}*/
|
||||
//优化岗位名称查询,只有命中岗位名称或者分类就行
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasCate) {
|
||||
sub.or().eq(ESJobDocument::getJobCategory, cateStr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(esJobSearch.getLongitude()!=null){
|
||||
@@ -520,13 +539,13 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
List<Integer> integers = StringUtil.convertStringToIntegerList(esJobSearch.getExperience());
|
||||
wrapper.and(x->x.in(ESJobDocument::getExperience_int,integers));//精准查询
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){
|
||||
/*if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){
|
||||
//wrapper.and(x->x.eq(ESJobDocument::getJobCategory,esJobSearch.getJobCategory()));
|
||||
String targetValue = esJobSearch.getJobCategory();
|
||||
wrapper.and(x -> x.like(ESJobDocument::getJobCategory, targetValue)
|
||||
.or()
|
||||
.like(ESJobDocument::getJobTitle, targetValue));
|
||||
}
|
||||
}*/
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getScale())){
|
||||
//Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale());
|
||||
//wrapper.and(x->x.le(ESJobDocument::getScale,maxValue));
|
||||
|
||||
Reference in New Issue
Block a user