mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 18:36:51 +08:00
ES去掉老师的高亮显红色
This commit is contained in:
@@ -438,7 +438,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
HighlightBuilder highlightBuilder = new HighlightBuilder();
|
||||
|
||||
highlightBuilder.requireFieldMatch(true);//是否多个字段都高亮
|
||||
highlightBuilder.preTags("<span style='color:red'>");//前缀后缀
|
||||
highlightBuilder.preTags("<span style='color:#3e7fff'>");//前缀后缀
|
||||
highlightBuilder.postTags("</span>");
|
||||
|
||||
HighlightBuilder.Field nameHighlight=new HighlightBuilder.Field("name");
|
||||
@@ -462,7 +462,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
|
||||
SearchResponse response = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||
SearchHits hits = response.getHits();
|
||||
log.info("共查询到 : "+hits.getTotalHits());
|
||||
//log.info("共查询到 : "+hits.getTotalHits());
|
||||
for (SearchHit hit : hits) {
|
||||
|
||||
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
|
||||
@@ -494,15 +494,15 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
||||
}
|
||||
cft.setSummary(fmtStr.toString());
|
||||
}
|
||||
|
||||
if(teacher!= null){
|
||||
Text[] fragments = teacher.fragments();
|
||||
StringBuffer fmtStr = new StringBuffer("");
|
||||
for (Text fragment : fragments) {
|
||||
fmtStr.append(fragment);
|
||||
}
|
||||
cft.setTeacher(fmtStr.toString());
|
||||
}
|
||||
//去掉老师的高亮显
|
||||
// if(teacher!= null){
|
||||
// Text[] fragments = teacher.fragments();
|
||||
// StringBuffer fmtStr = new StringBuffer("");
|
||||
// for (Text fragment : fragments) {
|
||||
// fmtStr.append(fragment);
|
||||
// }
|
||||
// cft.setTeacher(fmtStr.toString());
|
||||
// }
|
||||
|
||||
if(keywords!= null){
|
||||
Text[] fragments = keywords.fragments();
|
||||
|
||||
Reference in New Issue
Block a user