This commit is contained in:
wangzhijiang
2022-08-24 15:44:53 +08:00
parent d08fd4c27f
commit f2f985e7a8
@@ -1152,10 +1152,10 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
Map<String, Object> map4 = new HashMap<>();
if("title".equals(field)){
map3.put("boost",1);
}else if("file_text".equals(field)){
map3.put("boost",0.01);
}else if("content".equals(field)){
map3.put("boost",0.01);
}else if("file_text".equals(field)){
map3.put("boost",0.01);
}
//特殊处理标题字段
if (field.equals("title")){
@@ -1172,7 +1172,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
//高亮
if(!"flag".equals(field)){
highlight(mapHighlight, field);
problemKnowledgeBaseHighlight(mapHighlight, field);
}
}
mapHighlight1.put("fields",mapHighlight);
@@ -1219,7 +1219,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
queryMapJsonTwo.add(queryMap);
//高亮
if(!"flag".equals(field)){
highlight(mapHighlight, field);
problemKnowledgeBaseHighlight(mapHighlight, field);
}
}
mapHighlight1.put("fields",mapHighlight);
@@ -1402,6 +1402,25 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService {
}
}
/**
* 问题知识库高亮设置
* @param mapHighlight
* @param key
*/
private void problemKnowledgeBaseHighlight(Map<String, Object> mapHighlight, String key) {
Map<String, Object> mapTemp = new HashMap<>();
List<String> list = new ArrayList<>();
list.add("<text class='highlight-class'>");
List<String> list1 = new ArrayList<>();
list1.add("</text>");
mapTemp.put("pre_tags", list);
mapTemp.put("post_tags", list1);
mapTemp.put("fragment_size", 2000);//高亮字段内容长度,去除html样式标签,统计字数,设置为200
mapTemp.put("number_of_fragments", 1);//高亮内容默认分为5段, 此处设置为一段
mapTemp.put("type", "plain");
mapHighlight.put(key, mapTemp);
}
}