mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-07 09:39:04 +08:00
v2.0.0-beta5
PR细节优化,高亮效率优化
This commit is contained in:
parent
8bd4815a60
commit
88095f5e88
@ -1055,9 +1055,9 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
T entity = JSON.parseObject(searchHit.getSourceAsString(), entityClass, entityInfo.getExtraProcessor());
|
T entity = JSON.parseObject(searchHit.getSourceAsString(), entityClass, entityInfo.getExtraProcessor());
|
||||||
|
|
||||||
// 主类中高亮字段处理
|
// 主类中高亮字段处理
|
||||||
if (CollectionUtils.isNotEmpty(entityInfo.getHighlightParams())) {
|
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
|
||||||
|
if (CollectionUtils.isNotEmpty(entityInfo.getHighlightParams()) && CollectionUtils.isNotEmpty(highlightFields)) {
|
||||||
Map<String, String> highlightFieldMap = getHighlightFieldMap();
|
Map<String, String> highlightFieldMap = getHighlightFieldMap();
|
||||||
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
|
|
||||||
highlightFields.forEach((key, value) -> {
|
highlightFields.forEach((key, value) -> {
|
||||||
String highLightValue = Arrays.stream(value.getFragments()).map(Text::string).collect(Collectors.joining());
|
String highLightValue = Arrays.stream(value.getFragments()).map(Text::string).collect(Collectors.joining());
|
||||||
setHighlightValue(entity, highlightFieldMap.get(key), highLightValue);
|
setHighlightValue(entity, highlightFieldMap.get(key), highLightValue);
|
||||||
@ -1104,14 +1104,13 @@ public class BaseEsMapperImpl<T> implements BaseEsMapper<T> {
|
|||||||
if (CollectionUtils.isNotEmpty(highlightFields) && nestedIdentity != null) {
|
if (CollectionUtils.isNotEmpty(highlightFields) && nestedIdentity != null) {
|
||||||
highlightFields.forEach((k1, v1) -> {
|
highlightFields.forEach((k1, v1) -> {
|
||||||
String highLightContent = Arrays.stream(v1.getFragments()).map(Text::string).collect(Collectors.joining());
|
String highLightContent = Arrays.stream(v1.getFragments()).map(Text::string).collect(Collectors.joining());
|
||||||
|
|
||||||
SearchHit.NestedIdentity tmpNestedIdentity = nestedIdentity;
|
SearchHit.NestedIdentity tmpNestedIdentity = nestedIdentity;
|
||||||
List<String> pathList = new ArrayList<>();
|
List<String> pathList = new ArrayList<>();
|
||||||
while (tmpNestedIdentity != null) {
|
while (tmpNestedIdentity != null) {
|
||||||
pathList.add(tmpNestedIdentity.getField().toString());
|
Optional.ofNullable(tmpNestedIdentity.getField()).ifPresent(field -> pathList.add(field.toString()));
|
||||||
tmpNestedIdentity = tmpNestedIdentity.getChild();
|
tmpNestedIdentity = tmpNestedIdentity.getChild();
|
||||||
}
|
}
|
||||||
String highLightField = k1.replace(String.join(STR_SIGN, pathList) + STR_SIGN, "");
|
String highLightField = k1.replace(String.join(STR_SIGN, pathList) + STR_SIGN, EMPTY_STR);
|
||||||
processInnerHighlight(nestedIdentity.getField().string(), root, nestedIdentity,
|
processInnerHighlight(nestedIdentity.getField().string(), root, nestedIdentity,
|
||||||
highLightField, highLightContent, nestedHighlightFieldMap);
|
highLightField, highLightContent, nestedHighlightFieldMap);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user