1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

Fix HighlightBuilder's package path

This commit is contained in:
dengchao@xgtl 2020-04-16 10:16:06 +08:00
parent 72545a9db7
commit 7bfe151a0e
6 changed files with 420 additions and 420 deletions

View File

@ -21,7 +21,7 @@ import com.chatopera.cc.model.Topic;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.Operator;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -19,7 +19,7 @@ package com.chatopera.cc.persistence.es;
import com.chatopera.cc.model.KbsTopic;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -20,7 +20,7 @@ import com.chatopera.cc.basic.MainContext;
import com.chatopera.cc.model.QuickReply;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -20,7 +20,7 @@ import com.chatopera.cc.model.Topic;
import com.chatopera.cc.persistence.repository.XiaoEUKResultMapper;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -27,7 +27,7 @@ import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.highlight.HighlightField;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Document;
@ -45,7 +45,7 @@ import org.springframework.data.mapping.context.MappingContext;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class UKResultMapper extends AbstractResultMapper {
@ -96,7 +96,7 @@ public class UKResultMapper extends AbstractResultMapper {
public <T> T mapEntity(String source , SearchHit hit , Class<T> clazz) {
T t = mapEntity(source , clazz) ;
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
HighlightField highlightNameField = highlightFields.get("title");
HighlightField contentHightlightField = highlightFields.get("content");
try {
@ -108,8 +108,8 @@ public class UKResultMapper extends AbstractResultMapper {
}
PropertyUtils.setProperty(t, "id" , hit.getId());
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
e.printStackTrace();
}
return t;
}
@ -154,18 +154,18 @@ public class UKResultMapper extends AbstractResultMapper {
for (SearchHitField value : values) {
if (value.getValues().size() > 1) {
generator.writeArrayFieldStart(value.getName());
for (Object val : value.getValues()) {
generator.writeObject(val);
}
generator.writeEndArray();
} else {
generator.writeObjectField(value.getName(), value.getValue());
}
}
generator.writeEndObject();
generator.flush();
return new String(stream.toByteArray(), Charset.forName("UTF-8"));
} catch (IOException e) {
for (Object val : value.getValues()) {
generator.writeObject(val);
}
generator.writeEndArray();
} else {
generator.writeObjectField(value.getName(), value.getValue());
}
}
generator.writeEndObject();
generator.flush();
return new String(stream.toByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
return null;
}
}
@ -199,7 +199,7 @@ public class UKResultMapper extends AbstractResultMapper {
ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
// Only deal with String because ES generated Ids are strings !
// Only deal with String because ES generated Ids are strings !
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
}

View File

@ -27,7 +27,7 @@ import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import org.elasticsearch.search.highlight.HighlightField;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.data.elasticsearch.annotations.Document;
@ -45,7 +45,7 @@ import org.springframework.data.mapping.context.MappingContext;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class XiaoEUKResultMapper extends AbstractResultMapper {
@ -96,7 +96,7 @@ public class XiaoEUKResultMapper extends AbstractResultMapper {
public <T> T mapEntity(String source , SearchHit hit , Class<T> clazz) {
T t = mapEntity(source , clazz) ;
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
Map<String, HighlightField> highlightFields = hit.getHighlightFields();
HighlightField highlightNameField = highlightFields.get("title");
HighlightField contentHightlightField = highlightFields.get("content");
try {
@ -108,8 +108,8 @@ public class XiaoEUKResultMapper extends AbstractResultMapper {
}
PropertyUtils.setProperty(t, "id" , hit.getId());
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
e.printStackTrace();
}
return t;
}
@ -154,18 +154,18 @@ public class XiaoEUKResultMapper extends AbstractResultMapper {
for (SearchHitField value : values) {
if (value.getValues().size() > 1) {
generator.writeArrayFieldStart(value.getName());
for (Object val : value.getValues()) {
generator.writeObject(val);
}
generator.writeEndArray();
} else {
generator.writeObjectField(value.getName(), value.getValue());
}
}
generator.writeEndObject();
generator.flush();
return new String(stream.toByteArray(), Charset.forName("UTF-8"));
} catch (IOException e) {
for (Object val : value.getValues()) {
generator.writeObject(val);
}
generator.writeEndArray();
} else {
generator.writeObjectField(value.getName(), value.getValue());
}
}
generator.writeEndObject();
generator.flush();
return new String(stream.toByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
return null;
}
}
@ -199,7 +199,7 @@ public class XiaoEUKResultMapper extends AbstractResultMapper {
ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
// Only deal with String because ES generated Ids are strings !
// Only deal with String because ES generated Ids are strings !
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
}