DATAES-566 - Eliminate double SearchHit source to string conversion in DefaultResultMapper.

Original pull request: #275
This commit is contained in:
Dmitriy Yakovlev 2019-04-19 12:36:10 +03:00 committed by xhaggi
parent e7857e874f
commit 4ab8af5116

View File

@ -61,6 +61,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
* @author Ilkang Na
* @author Sascha Woo
* @author Christoph Strobl
* @author Dmitriy Yakovlev
*/
public class DefaultResultMapper extends AbstractResultMapper {
@ -105,8 +106,9 @@ public class DefaultResultMapper extends AbstractResultMapper {
for (SearchHit hit : response.getHits()) {
if (hit != null) {
T result = null;
if (!StringUtils.isEmpty(hit.getSourceAsString())) {
result = mapEntity(hit.getSourceAsString(), clazz);
String hitSourceAsString = hit.getSourceAsString();
if (!StringUtils.isEmpty(hitSourceAsString)) {
result = mapEntity(hitSourceAsString, clazz);
} else {
result = mapEntity(hit.getFields().values(), clazz);
}