文档库--搜索
This commit is contained in:
+19
-14
@@ -240,8 +240,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
//// Map<String, Object> map2 = new HashMap<>();
|
//// Map<String, Object> map2 = new HashMap<>();
|
||||||
//// map2.put("content",selectValue);
|
//// map2.put("content",selectValue);
|
||||||
// Map<String,Object> map3 = new HashMap<>();
|
// Map<String,Object> map3 = new HashMap<>();
|
||||||
// map3.put("pre_tags","<span class='highlight-class'>");
|
// map3.put("pre_tags","<text class='highlight-class'>");
|
||||||
// map3.put("post_tags","</span>");
|
// map3.put("post_tags","</text>");
|
||||||
// for (String s : listTemp) {
|
// for (String s : listTemp) {
|
||||||
// Map<String, Object> map4 = new HashMap<>();
|
// Map<String, Object> map4 = new HashMap<>();
|
||||||
// Map<String, Object> queryMap = new HashMap<>();
|
// Map<String, Object> queryMap = new HashMap<>();
|
||||||
@@ -269,8 +269,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
// //封装高亮查询条件
|
// //封装高亮查询条件
|
||||||
// Map<String, Object> map1 = new HashMap<>();
|
// Map<String, Object> map1 = new HashMap<>();
|
||||||
// Map<String,Object> map3 = new HashMap<>();
|
// Map<String,Object> map3 = new HashMap<>();
|
||||||
// map3.put("pre_tags","<span class='highlight-class'>");
|
// map3.put("pre_tags","<text class='highlight-class'>");
|
||||||
// map3.put("post_tags","</span>");
|
// map3.put("post_tags","</text>");
|
||||||
// map1.put("content", map3);
|
// map1.put("content", map3);
|
||||||
// highlightMap.put("fields", map1);
|
// highlightMap.put("fields", map1);
|
||||||
//
|
//
|
||||||
@@ -368,7 +368,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
for (int i = 0; i < value.length(); i++) {
|
for (int i = 0; i < value.length(); i++) {
|
||||||
String chStr = String.valueOf(value.charAt(i));
|
String chStr = String.valueOf(value.charAt(i));
|
||||||
if (selectValueTwo.contains(String.valueOf(chStr))) {
|
if (selectValueTwo.contains(String.valueOf(chStr))) {
|
||||||
chStr = "<span class='highlight-class'>" + chStr + "</span>";
|
chStr = "<text class='highlight-class'>" + chStr + "</text>";
|
||||||
}
|
}
|
||||||
sb.append(String.valueOf(chStr));
|
sb.append(String.valueOf(chStr));
|
||||||
}
|
}
|
||||||
@@ -380,7 +380,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
mapListTwo.add(mapSource);
|
mapListTwo.add(mapSource);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//首次查询
|
//首次查询(没有输入查询条件)
|
||||||
mapList.add(mapSource);
|
mapList.add(mapSource);
|
||||||
|
|
||||||
//目前只能处理单字段高亮(多字段高亮问题解决后可以用此方法)
|
//目前只能处理单字段高亮(多字段高亮问题解决后可以用此方法)
|
||||||
@@ -395,8 +395,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//处理高亮module_type,title,serial_number,file_text
|
//处理高亮module_type,title,serial_number,file_text(输入查询条件后,处理高亮字段)
|
||||||
|
if(StringUtils.isNotBlank(selectValue)){
|
||||||
for (Map.Entry<String, Object> entry : mapSource.entrySet()) {
|
for (Map.Entry<String, Object> entry : mapSource.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = null;
|
String value = null;
|
||||||
@@ -413,8 +413,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
for (int i = 0; i < value.length(); i++) {
|
for (int i = 0; i < value.length(); i++) {
|
||||||
String chStr = String.valueOf(value.charAt(i));
|
String chStr = String.valueOf(value.charAt(i));
|
||||||
if (selectValue.contains(String.valueOf(chStr))) {
|
if (selectValue.contains(String.valueOf(chStr))) {
|
||||||
chStr = "<span class='highlight-class'>" + chStr + "</span>";
|
chStr = "<text class='highlight-class'>" + chStr + "</text>";
|
||||||
int c = 0;
|
|
||||||
}
|
}
|
||||||
sb.append(String.valueOf(chStr));
|
sb.append(String.valueOf(chStr));
|
||||||
}
|
}
|
||||||
@@ -424,6 +423,8 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//若一条标准含有多条发布稿或报批稿等文件,需要对每个附件进行搜索并多行展示,
|
//若一条标准含有多条发布稿或报批稿等文件,需要对每个附件进行搜索并多行展示,
|
||||||
@@ -432,14 +433,14 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
List<Map<String, Object>> result = new ArrayList<>();
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
List<String> idList = new ArrayList<>();
|
List<String> idList = new ArrayList<>();
|
||||||
for (Map<String, Object> map : listNew) {
|
for (Map<String, Object> map : listNew) {
|
||||||
idList.add((String) map.get("_id"));
|
// idList.add((String) map.get("_id"));
|
||||||
Map<String, Object> mapSource = (Map<String, Object>) map.get("_source");
|
Map<String, Object> mapSource = (Map<String, Object>) map.get("_source");
|
||||||
String moduleType = (String) mapSource.get("module_type");
|
String moduleType = (String) mapSource.get("module_type");
|
||||||
String serialNumber = (String) mapSource.get("serial_number");
|
String serialNumber = (String) mapSource.get("serial_number");
|
||||||
String title = (String) mapSource.get("title");
|
String title = (String) mapSource.get("title");
|
||||||
String content = (String) mapSource.get("content");
|
String content = (String) mapSource.get("content");
|
||||||
String id = (String) mapSource.get("id");
|
String id = (String) mapSource.get("id");
|
||||||
int count = 0;
|
// int count = 0;
|
||||||
if(StringUtils.isNotBlank(selectValueTwo)){
|
if(StringUtils.isNotBlank(selectValueTwo)){
|
||||||
//二次查询
|
//二次查询
|
||||||
for (Map.Entry<String, Object> entry : mapSource.entrySet()) {
|
for (Map.Entry<String, Object> entry : mapSource.entrySet()) {
|
||||||
@@ -447,6 +448,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
if("file_text".equals(key)){
|
if("file_text".equals(key)){
|
||||||
for (List<String> valueList : (List<List<String>>) entry.getValue()) {
|
for (List<String> valueList : (List<List<String>>) entry.getValue()) {
|
||||||
for (String s : valueList) {
|
for (String s : valueList) {
|
||||||
|
int count = 0;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (StringUtils.isNotBlank(s)) {
|
if (StringUtils.isNotBlank(s)) {
|
||||||
//判断value中是否包含二次搜索中的字符
|
//判断value中是否包含二次搜索中的字符
|
||||||
@@ -455,7 +457,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
String chStr = String.valueOf(s.charAt(i));
|
String chStr = String.valueOf(s.charAt(i));
|
||||||
if (selectValue.contains(String.valueOf(chStr))) {
|
if (selectValue.contains(String.valueOf(chStr))) {
|
||||||
chStr = "<span class='highlight-class'>" + chStr + "</span>";
|
chStr = "<text class='highlight-class'>" + chStr + "</text>";
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
sb.append(String.valueOf(chStr));
|
sb.append(String.valueOf(chStr));
|
||||||
@@ -471,6 +473,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
mapTemp.put("content",content);
|
mapTemp.put("content",content);
|
||||||
mapTemp.put("file_text",sb.toString());
|
mapTemp.put("file_text",sb.toString());
|
||||||
result.add(mapTemp);
|
result.add(mapTemp);
|
||||||
|
idList.add(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,12 +486,13 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
if("file_text".equals(key)){
|
if("file_text".equals(key)){
|
||||||
for (List<String> valueList : (List<List<String>>) entry.getValue()) {
|
for (List<String> valueList : (List<List<String>>) entry.getValue()) {
|
||||||
for (String s : valueList) {
|
for (String s : valueList) {
|
||||||
|
int count = 0;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (StringUtils.isNotBlank(s)) {
|
if (StringUtils.isNotBlank(s)) {
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
String chStr = String.valueOf(s.charAt(i));
|
String chStr = String.valueOf(s.charAt(i));
|
||||||
if (selectValue.contains(String.valueOf(chStr))) {
|
if (selectValue.contains(String.valueOf(chStr))) {
|
||||||
chStr = "<span class='highlight-class'>" + chStr + "</span>";
|
chStr = "<text class='highlight-class'>" + chStr + "</text>";
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
sb.append(String.valueOf(chStr));
|
sb.append(String.valueOf(chStr));
|
||||||
@@ -503,6 +507,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
|
|||||||
mapTemp.put("content",content);
|
mapTemp.put("content",content);
|
||||||
mapTemp.put("file_text",sb.toString());
|
mapTemp.put("file_text",sb.toString());
|
||||||
result.add(mapTemp);
|
result.add(mapTemp);
|
||||||
|
idList.add(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user