搜索中心--文档库(输入框搜索)

This commit is contained in:
zhn
2023-10-27 10:57:31 +08:00
parent bee8cc8ebb
commit 8436d528ba
@@ -330,26 +330,48 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
String value = (String) entry.getValue(); String value = (String) entry.getValue();
if (ObjectUtils.isNotEmpty(value)) { if (ObjectUtils.isNotEmpty(value)) {
for (String s : value.split(",")) { for (String s : value.split(",")) {
Map<String, Object> map = new HashMap<>(); JSONArray should = new JSONArray();
Map<String, Object> queryMap = new HashMap<>(); s = s.toLowerCase();
Map<String, Object> queryMapTemp = new HashMap<>(); for (String valueTemp : s.split(" ")) {
Map<String,Object> mapTemp = new HashMap();
if (key.equals("serial_number")){ mapTemp.put(key,"*"+valueTemp+"*");
s = s.toLowerCase(); Map<String,Object> map1 = new HashMap<>();
queryMap.put(key, "*" + s + "*"); map1.put("wildcard",mapTemp);
map.put("wildcard", queryMap); should.add(map1);
} else {
s = s.toLowerCase();
queryMapTemp.put("query", s);
queryMapTemp.put("minimum_should_match", 2);
queryMap.put(key, queryMapTemp);
map.put("match",queryMap);
} }
must.add(map); JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, should);
must.add(jsonObject);
} }
} }
} }
} }
//封装输入框查询条件
// if (ObjectUtils.isNotEmpty(inputMap)) {
// for (Map.Entry<String, Object> entry : inputMap.entrySet()) {
// String key = entry.getKey();
// String value = (String) entry.getValue();
// if (ObjectUtils.isNotEmpty(value)) {
// for (String s : value.split(",")) {
// Map<String, Object> map = new HashMap<>();
// Map<String, Object> queryMap = new HashMap<>();
// 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);
// map.put("match",queryMap);
// }
// must.add(map);
// }
// }
// }
// }
//封装下拉,树形查询条件 //封装下拉,树形查询条件
if (ObjectUtils.isNotEmpty(otherMap)) { if (ObjectUtils.isNotEmpty(otherMap)) {
for (Map.Entry<String, Object> entry : otherMap.entrySet()) { for (Map.Entry<String, Object> entry : otherMap.entrySet()) {