手机端搜索中心-文档库搜索完善.

This commit is contained in:
wangzhijiang
2023-06-20 16:07:28 +08:00
parent ad9f15116e
commit e267376165
@@ -141,19 +141,43 @@ public class SearchCenterServiceImpl implements ISearchCenterService {
fieldList.add("serial_number");
fieldList.add("title");
fieldList.add("content");
fieldList.add("flag");
JSONArray queryMapJsonAll = new JSONArray();
JSONArray queryJsonMustNot = new JSONArray();
JSONArray queryMapInputJson = new JSONArray();
Map<String, Object> mapHighlight = new HashMap<>();
Map<String, Object> mapHighlight1 = new HashMap<>();
String selectValue = (String) params.get("selectValue");
if(StringUtils.isNotBlank(selectValue)){
Map<String,Object> map = new HashMap<>();
Map<String,Object> map1 = new HashMap<>();
Map<String,Object> map2 = new HashMap<>();
map.put("query",SEARCH_FLAG);
map1.put("flag",map);
map2.put("match",map1);
queryJsonMustNot.add(map2);
}else {
selectValue = SEARCH_FLAG;
}
if (StringUtils.isNotBlank(selectValue)) {
for (String field : fieldList) {
this.setQueryMapJson(queryMapInputJson, selectValue, field);
//高亮
this.wdkHighlight(mapHighlight, field);
if(!"flag".equals(field)){
this.wdkHighlight(mapHighlight, field);
} else {
// query_string查询
Map<String, Object> map25 = new HashMap<>();
Map<String, Object> map45 = new HashMap<>();
map25.put("query", selectValue);
map25.put("fields", fieldList.toArray());
map25.put("allow_leading_wildcard", false); //禁用了前置通配符
map45.put("query_string", map25);
queryMapInputJson.add(map45);
}
}
mapHighlight1.put("fields", mapHighlight);
@@ -197,7 +221,7 @@ public class SearchCenterServiceImpl implements ISearchCenterService {
pageSize,
cut,
querySort,
null,
queryJsonMustNot,
null
);
return Result.OK(page);