搜索中心--文档库段落

This commit is contained in:
zhn
2022-09-01 09:48:29 +08:00
parent 75f45498f4
commit 1b2c3fdeed
@@ -328,9 +328,11 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
Map<String, Object> queryMapTemp = new HashMap<>();
if (key.equals("serial_number")){
s = s.toLowerCase();
queryMap.put(key, "*" + s + "*");
map.put("wildcard", queryMap);
} else {
s = s.toLowerCase();
queryMapTemp.put("query", s);
queryMapTemp.put("minimum_should_match", 2);
queryMap.put(key, queryMapTemp);
@@ -919,8 +921,27 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
*/
@Override
public IPage getParagraphInfoList(Map<String, Object> map) {
//指定module_type_flag= WDK
JSONArray queryJsonMust = new JSONArray();
Map<String, Object> mapModule = new HashMap<>();
Map<String, Object> mapModule1 = new HashMap<>();
Map<String, Object> mapModule2 = new HashMap<>();
mapModule.put("query", "WDK");
mapModule1.put("module_type_flag", mapModule);
mapModule2.put("match", mapModule1);
queryJsonMust.add(mapModule2);
//段落, 有条件的时候,查询的数据中不含有魑的数据
JSONArray queryJsonMustNot = new JSONArray();
if(ObjectUtils.isEmpty(map.get("mapOne"))){
((Map<String, Object>) map.get("mapOne")).put("flag",SEARCH_FLAG);
}else{
Map<String, Object> mapTemp = new HashMap<>();
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
mapTemp.put("query", SEARCH_FLAG);
map1.put("flag", mapTemp);
map2.put("match", map1);
queryJsonMustNot.add(map2);
}
String cut = (String) map.get("cut");
//module_type 代表文档库的段落
@@ -956,17 +977,20 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
JSONArray queryMapJsonAll = new JSONArray();
//首次查询条件
if (ObjectUtils.isNotEmpty(mapOne)) {
if(StringUtils.isNotBlank((String)mapOne.get("title"))
|| StringUtils.isNotBlank((String)mapOne.get("serial_number"))){
Map<String, Object> queryMap = new HashMap<>();
Map<String, Object> queryMapTemp = new HashMap<>();
queryMapTemp.put("flag",SEARCH_FLAG );
queryMap.put("match_phrase", queryMapTemp);
queryMapJsonTemp.add(queryMap);
}
// if(StringUtils.isNotBlank((String)mapOne.get("title"))
// || StringUtils.isNotBlank((String)mapOne.get("serial_number"))){
// Map<String, Object> queryMap = new HashMap<>();
// Map<String, Object> queryMapTemp = new HashMap<>();
// queryMapTemp.put("flag",SEARCH_FLAG );
// queryMap.put("match_phrase", queryMapTemp);
// queryMapJsonTemp.add(queryMap);
// }
for (Map.Entry<String, Object> entry : mapOne.entrySet()) {
String key = entry.getKey();
String value = (String) entry.getValue();
if("serial_number".equals(key) || "title".equals(key) || "file_text".equals(key)){
value = value.toLowerCase();
}
if (ObjectUtils.isNotEmpty(value)) {
for (String s : value.split(",")) {
Map<String, Object> queryMap = new HashMap<>();
@@ -1007,6 +1031,10 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null);
queryMapJsonAll.add(jsonObject);
}
if(CollectionUtils.isNotEmpty(queryJsonMust)){
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryJsonMust, null, null);
queryMapJsonAll.add(jsonObject);
}
}
String ids = (String) mapTwo.get("ids");
@@ -1113,7 +1141,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
IPage iPage = getiPage(selectValue, selectValueTwo, queryMapJsonAll, mapHighlight1,null,
pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort,null);
pageNo, pageSize, paragraphFlag,(String) map.get("cut"),sort,queryJsonMustNot);
return iPage;
}