修改去掉推荐注释的放宽条件
This commit is contained in:
@@ -264,50 +264,50 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
|
||||
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
|
||||
// if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// // 定义要逐步放宽的搜索条件字段
|
||||
// List<Runnable> relaxConditions = new ArrayList<>();
|
||||
// relaxConditions.add(() -> newSearch.setArea(null));
|
||||
// relaxConditions.add(() -> newSearch.setExperience(null));
|
||||
// relaxConditions.add(() -> newSearch.setMaxSalary(null));
|
||||
// relaxConditions.add(() -> newSearch.setMinSalary(null));
|
||||
// relaxConditions.add(() -> newSearch.setEducation(null));
|
||||
// relaxConditions.add(()-> newSearch.setJobTitle(null));
|
||||
// // 保存所有查询到的文档
|
||||
// List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
|
||||
//
|
||||
// // 记录已经放宽的条件数量
|
||||
// int relaxedConditions = 0;
|
||||
//
|
||||
// // 继续放宽条件直到满足分页或所有条件都已放宽
|
||||
// while (allDocuments.size() < esJobSearch.getPageSize()
|
||||
// && relaxedConditions < relaxConditions.size()) {
|
||||
// // 放宽下一个条件
|
||||
// relaxConditions.get(relaxedConditions).run();
|
||||
// relaxedConditions++;
|
||||
//
|
||||
// // 查询新增的文档(不包含之前已经查询到的)
|
||||
// wrapper = getWrapper(newSearch, jobIds);
|
||||
// wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
|
||||
// if (!allDocuments.isEmpty()) {
|
||||
// // 排除已经查询到的文档ID
|
||||
// Set<String> existingIds = allDocuments.stream()
|
||||
// .map(ESJobDocument::getId)
|
||||
// .collect(Collectors.toSet());
|
||||
// wrapper.not().in(ESJobDocument::getId, existingIds);
|
||||
// }
|
||||
//
|
||||
// List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
// allDocuments.addAll(newDocuments);
|
||||
// }
|
||||
//
|
||||
// // 如果总数超过分页大小,截取所需数量
|
||||
// if (allDocuments.size() > esJobSearch.getPageSize()) {
|
||||
// esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
|
||||
// } else {
|
||||
// esJobDocuments = allDocuments;
|
||||
// }
|
||||
// }
|
||||
if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// 定义要逐步放宽的搜索条件字段
|
||||
List<Runnable> relaxConditions = new ArrayList<>();
|
||||
relaxConditions.add(() -> newSearch.setArea(null));
|
||||
relaxConditions.add(() -> newSearch.setExperience(null));
|
||||
relaxConditions.add(() -> newSearch.setMaxSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setMinSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setEducation(null));
|
||||
relaxConditions.add(()-> newSearch.setJobTitle(null));
|
||||
// 保存所有查询到的文档
|
||||
List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
|
||||
|
||||
// 记录已经放宽的条件数量
|
||||
int relaxedConditions = 0;
|
||||
|
||||
// 继续放宽条件直到满足分页或所有条件都已放宽
|
||||
while (allDocuments.size() < esJobSearch.getPageSize()
|
||||
&& relaxedConditions < relaxConditions.size()) {
|
||||
// 放宽下一个条件
|
||||
relaxConditions.get(relaxedConditions).run();
|
||||
relaxedConditions++;
|
||||
|
||||
// 查询新增的文档(不包含之前已经查询到的)
|
||||
wrapper = getWrapper(newSearch, jobIds);
|
||||
wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
|
||||
if (!allDocuments.isEmpty()) {
|
||||
// 排除已经查询到的文档ID
|
||||
Set<String> existingIds = allDocuments.stream()
|
||||
.map(ESJobDocument::getId)
|
||||
.collect(Collectors.toSet());
|
||||
wrapper.not().in(ESJobDocument::getId, existingIds);
|
||||
}
|
||||
|
||||
List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
allDocuments.addAll(newDocuments);
|
||||
}
|
||||
|
||||
// 如果总数超过分页大小,截取所需数量
|
||||
if (allDocuments.size() > esJobSearch.getPageSize()) {
|
||||
esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
|
||||
} else {
|
||||
esJobDocuments = allDocuments;
|
||||
}
|
||||
}
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
@@ -926,50 +926,50 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
wrapper.limit(esJobSearch.getPageSize());
|
||||
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
|
||||
// if (esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// // 定义要逐步放宽的搜索条件字段
|
||||
// List<Runnable> relaxConditions = new ArrayList<>();
|
||||
// relaxConditions.add(() -> newSearch.setArea(null));
|
||||
// relaxConditions.add(() -> newSearch.setExperience(null));
|
||||
// relaxConditions.add(() -> newSearch.setMaxSalary(null));
|
||||
// relaxConditions.add(() -> newSearch.setMinSalary(null));
|
||||
// relaxConditions.add(() -> newSearch.setEducation(null));
|
||||
// relaxConditions.add(()-> newSearch.setJobTitle(null));
|
||||
// // 保存所有查询到的文档
|
||||
// List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
|
||||
//
|
||||
// // 记录已经放宽的条件数量
|
||||
// int relaxedConditions = 0;
|
||||
//
|
||||
// // 继续放宽条件直到满足分页或所有条件都已放宽
|
||||
// while (allDocuments.size() < esJobSearch.getPageSize()
|
||||
// && relaxedConditions < relaxConditions.size()) {
|
||||
// // 放宽下一个条件
|
||||
// relaxConditions.get(relaxedConditions).run();
|
||||
// relaxedConditions++;
|
||||
//
|
||||
// // 查询新增的文档(不包含之前已经查询到的)
|
||||
// wrapper = getWrapper(newSearch, jobIds);
|
||||
// wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
|
||||
// if (!allDocuments.isEmpty()) {
|
||||
// // 排除已经查询到的文档ID
|
||||
// Set<String> existingIds = allDocuments.stream()
|
||||
// .map(ESJobDocument::getId)
|
||||
// .collect(Collectors.toSet());
|
||||
// wrapper.not().in(ESJobDocument::getId, existingIds);
|
||||
// }
|
||||
//
|
||||
// List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
// allDocuments.addAll(newDocuments);
|
||||
// }
|
||||
//
|
||||
// // 如果总数超过分页大小,截取所需数量
|
||||
// if (allDocuments.size() > esJobSearch.getPageSize()) {
|
||||
// esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
|
||||
// } else {
|
||||
// esJobDocuments = allDocuments;
|
||||
// }
|
||||
// }
|
||||
if (esJobDocuments.size() < esJobSearch.getPageSize()) {
|
||||
// 定义要逐步放宽的搜索条件字段
|
||||
List<Runnable> relaxConditions = new ArrayList<>();
|
||||
relaxConditions.add(() -> newSearch.setArea(null));
|
||||
relaxConditions.add(() -> newSearch.setExperience(null));
|
||||
relaxConditions.add(() -> newSearch.setMaxSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setMinSalary(null));
|
||||
relaxConditions.add(() -> newSearch.setEducation(null));
|
||||
relaxConditions.add(()-> newSearch.setJobTitle(null));
|
||||
// 保存所有查询到的文档
|
||||
List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
|
||||
|
||||
// 记录已经放宽的条件数量
|
||||
int relaxedConditions = 0;
|
||||
|
||||
// 继续放宽条件直到满足分页或所有条件都已放宽
|
||||
while (allDocuments.size() < esJobSearch.getPageSize()
|
||||
&& relaxedConditions < relaxConditions.size()) {
|
||||
// 放宽下一个条件
|
||||
relaxConditions.get(relaxedConditions).run();
|
||||
relaxedConditions++;
|
||||
|
||||
// 查询新增的文档(不包含之前已经查询到的)
|
||||
wrapper = getWrapper(newSearch, jobIds);
|
||||
wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
|
||||
if (!allDocuments.isEmpty()) {
|
||||
// 排除已经查询到的文档ID
|
||||
Set<String> existingIds = allDocuments.stream()
|
||||
.map(ESJobDocument::getId)
|
||||
.collect(Collectors.toSet());
|
||||
wrapper.not().in(ESJobDocument::getId, existingIds);
|
||||
}
|
||||
|
||||
List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
|
||||
allDocuments.addAll(newDocuments);
|
||||
}
|
||||
|
||||
// 如果总数超过分页大小,截取所需数量
|
||||
if (allDocuments.size() > esJobSearch.getPageSize()) {
|
||||
esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
|
||||
} else {
|
||||
esJobDocuments = allDocuments;
|
||||
}
|
||||
}
|
||||
|
||||
return esJobDocuments;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user