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