二次检索
This commit is contained in:
@@ -52,6 +52,9 @@ public class SearchQuery {
|
||||
@Schema(description = "媒体类型:纸质/电子")
|
||||
private String mediaType;
|
||||
|
||||
@Schema(description = "媒体类型(多选,in):纸质/电子")
|
||||
private List<String> mediaTypes;
|
||||
|
||||
@Schema(description = "语种分组:chi 中文文献 / foreign 外文文献(首页前置筛选用)")
|
||||
private String languageGroup;
|
||||
|
||||
@@ -61,6 +64,9 @@ public class SearchQuery {
|
||||
@Schema(description = "来源馆(单选,左侧「来源院校」分面点选用)")
|
||||
private String sourceLibrary;
|
||||
|
||||
@Schema(description = "来源资源库名(多选,in)")
|
||||
private List<String> sourceRepos;
|
||||
|
||||
/** ---------------- 限定出版时段 ---------------- */
|
||||
@Schema(description = "出版年份起(含)", example = "2000")
|
||||
private String publishYearStart;
|
||||
@@ -72,6 +78,9 @@ public class SearchQuery {
|
||||
@Schema(description = "匹配精度:EQ 精确 / LEFT 前方一致 / RIGHT 后方一致 / LIKE 模糊(默认)")
|
||||
private String matchType = "LIKE";
|
||||
|
||||
@Schema(description = "在结果中搜索:新增关键词必须同时命中(AND 收窄当前结果集)")
|
||||
private String withinKeyword;
|
||||
|
||||
@Schema(description = "多字段逻辑:AND(默认) / OR")
|
||||
private String logic = "AND";
|
||||
|
||||
|
||||
+30
-8
@@ -99,6 +99,7 @@ public class SearchServiceImpl implements SearchService {
|
||||
|
||||
vo.setMediaTypeFacets(facet(query, "media_type"));
|
||||
vo.setSourceLibraryFacets(facet(query, "source_library"));
|
||||
vo.setSourceRepoFacets(facet(query, "source_repo"));
|
||||
vo.setClcFacets(clcFacet(query));
|
||||
vo.setYearStats(yearStats(query));
|
||||
|
||||
@@ -247,8 +248,11 @@ public class SearchServiceImpl implements SearchService {
|
||||
|| StrUtil.isNotBlank(q.getAuthor()) || StrUtil.isNotBlank(q.getPublisher())
|
||||
|| StrUtil.isNotBlank(q.getIsbn()) || StrUtil.isNotBlank(q.getCdoi())
|
||||
|| StrUtil.isNotBlank(q.getClcCode()) || CollectionUtil.isNotEmpty(q.getClcCodes())
|
||||
|| StrUtil.isNotBlank(q.getMediaType()) || StrUtil.isNotBlank(q.getLanguageGroup())
|
||||
|| StrUtil.isNotBlank(q.getMediaType()) || CollectionUtil.isNotEmpty(q.getMediaTypes())
|
||||
|| StrUtil.isNotBlank(q.getLanguageGroup())
|
||||
|| StrUtil.isNotBlank(q.getSourceLibrary()) || CollectionUtil.isNotEmpty(q.getSourceLibraries())
|
||||
|| CollectionUtil.isNotEmpty(q.getSourceRepos())
|
||||
|| StrUtil.isNotBlank(q.getWithinKeyword())
|
||||
|| StrUtil.isNotBlank(q.getPublishYearStart()) || StrUtil.isNotBlank(q.getPublishYearEnd());
|
||||
}
|
||||
|
||||
@@ -305,6 +309,14 @@ public class SearchServiceImpl implements SearchService {
|
||||
}
|
||||
}
|
||||
|
||||
// 在结果中搜索:每个新增关键词都必须命中(AND 收窄当前结果集)
|
||||
if (StrUtil.isNotBlank(q.getWithinKeyword())) {
|
||||
for (String kw : splitTerms(q.getWithinKeyword())) {
|
||||
w.and(x -> x.nested(y -> y.like("title", kw).or().like("author", kw).or()
|
||||
.like("keywords", kw).or().like("summary", kw).or().like("publisher", kw)));
|
||||
}
|
||||
}
|
||||
|
||||
applyMatch(w, "title", q.getTitle(), q.getMatchType());
|
||||
applyMatch(w, "author", q.getAuthor(), q.getMatchType());
|
||||
applyMatch(w, "publisher", q.getPublisher(), q.getMatchType());
|
||||
@@ -330,8 +342,13 @@ public class SearchServiceImpl implements SearchService {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (StrUtil.isNotBlank(q.getMediaType()) && !"media_type".equals(excludeColumn)) {
|
||||
w.eq("media_type", q.getMediaType());
|
||||
// 资源类型:单选或罗列多选(分面排除时跳过本列过滤,便于切换)
|
||||
if (!"media_type".equals(excludeColumn)) {
|
||||
if (CollectionUtil.isNotEmpty(q.getMediaTypes())) {
|
||||
w.in("media_type", q.getMediaTypes());
|
||||
} else if (StrUtil.isNotBlank(q.getMediaType())) {
|
||||
w.eq("media_type", q.getMediaType());
|
||||
}
|
||||
}
|
||||
// 语种分组:中文文献含 chi/zh/中文(库内有少量中文写法的脏数据);
|
||||
// 外文文献 = 不在中文集合内(NULL 语种视为未知,两侧都不计入外文组)
|
||||
@@ -340,12 +357,17 @@ public class SearchServiceImpl implements SearchService {
|
||||
} else if ("foreign".equalsIgnoreCase(q.getLanguageGroup())) {
|
||||
w.notIn("language", List.of("chi", "zh", "中文"));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(q.getSourceLibraries())) {
|
||||
w.in("source_library", q.getSourceLibraries());
|
||||
// 来源院校:多选(IN)或单选(分面排除时跳过本列过滤)
|
||||
if (!"source_library".equals(excludeColumn)) {
|
||||
if (CollectionUtil.isNotEmpty(q.getSourceLibraries())) {
|
||||
w.in("source_library", q.getSourceLibraries());
|
||||
} else if (StrUtil.isNotBlank(q.getSourceLibrary())) {
|
||||
w.eq("source_library", q.getSourceLibrary().trim());
|
||||
}
|
||||
}
|
||||
// 来源院校分面单选(前端点选传单数字段)
|
||||
if (StrUtil.isNotBlank(q.getSourceLibrary()) && !"source_library".equals(excludeColumn)) {
|
||||
w.eq("source_library", q.getSourceLibrary().trim());
|
||||
// 资源库名:多选(IN)
|
||||
if (CollectionUtil.isNotEmpty(q.getSourceRepos()) && !"source_repo".equals(excludeColumn)) {
|
||||
w.in("source_repo", q.getSourceRepos());
|
||||
}
|
||||
if (StrUtil.isNotBlank(q.getPublishYearStart())) {
|
||||
w.ge("publish_year", q.getPublishYearStart().trim());
|
||||
|
||||
@@ -25,6 +25,9 @@ public class SearchResultVO {
|
||||
@Schema(description = "来源院校分面")
|
||||
private List<FacetItem> sourceLibraryFacets;
|
||||
|
||||
@Schema(description = "资源库名分面")
|
||||
private List<FacetItem> sourceRepoFacets;
|
||||
|
||||
@Schema(description = "中图分类分面")
|
||||
private List<FacetItem> clcFacets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user