change: nutzboot-demo-simple-elasticsearch HighlightField

This commit is contained in:
Wizzercn 2018-06-16 14:32:36 +08:00
parent bc11db66f3
commit 3894c7f073

View File

@ -138,14 +138,14 @@ public class UserService {
Map<String, Object> source = searchHit.getSourceAsMap();
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
//name高亮
HighlightField nameField = highlightFields.get("user");
HighlightField nameField = highlightFields.get("name");
if (nameField != null) {
Text[] fragments = nameField.fragments();
String tmp = "";
for (Text text : fragments) {
tmp += text;
}
source.put("user", tmp);
source.put("name", tmp);
}
list.add(source);
});