搜索段落修改

This commit is contained in:
zhn
2022-04-07 21:08:38 +08:00
parent 3e776f5528
commit 2a7393d2b7
@@ -849,11 +849,20 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
Map<String, Object> mapTwo = (Map<String, Object>) map.get("mapTwo");
JSONArray queryMapJson = new JSONArray();
JSONArray queryMapJsonTemp = new JSONArray();
JSONArray queryMapJsonTwo = new JSONArray();
JSONArray queryMapJsonThree = new JSONArray();
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);
}
for (Map.Entry<String, Object> entry : mapOne.entrySet()) {
String key = entry.getKey();
String value = (String) entry.getValue();
@@ -867,10 +876,27 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
}
}
}
if(CollectionUtils.isNotEmpty(queryMapJson)){
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJson);
if(CollectionUtils.isNotEmpty(queryMapJsonTemp)){
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTemp, null, null);
queryMapJsonAll.add(jsonObject);
}
if(CollectionUtils.isNotEmpty(queryMapJson)){
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null);
queryMapJsonAll.add(jsonObject);
}
//首次查询所有的条件是and的关系
// if(ObjectUtils.isEmpty(mapTwo)){
// if(CollectionUtils.isNotEmpty(queryMapJson)){
// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null);
// queryMapJsonAll.add(jsonObject);
// }
// }else{
// if(CollectionUtils.isNotEmpty(queryMapJson)){
// JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJson);
// queryMapJsonAll.add(jsonObject);
// }
// }
}
String ids = (String) mapTwo.get("ids");
@@ -891,7 +917,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
}
}
if(CollectionUtils.isNotEmpty(queryMapJsonTwo)){
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(null, null, queryMapJsonTwo);
JSONObject jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJsonTwo, null, null);
queryMapJsonAll.add(jsonObject);
}
}