mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-06 17:18:57 +08:00
837 B
837 B
syntax:
// Do not specify the highlight tag, and use <em>your highlight content</em> to return the highlighted content by default
highLight(highlightField);
// Specify highlight label
highLight(highlightField,startTag, endTag)
@Test
public void testHighlight() throws IOException {
LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
String keyword = "World";
wrapper.match(Document::getContent,keyword);
wrapper.highLight(Document::getContent);
SearchResponse response = documentMapper.search(wrapper);
System.out.println(response);
}
Tips: If you need to highlight multiple fields, you can separate the fields with commas Must use SearchResponse to receive, otherwise there is no highlighted field in the return body