Skip to content

Commit 4ab8af5

Browse files
hobbutxhaggi
authored andcommitted
DATAES-566 - Eliminate double SearchHit source to string conversion in DefaultResultMapper.
Original pull request: spring-projects#275
1 parent e7857e8 commit 4ab8af5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* @author Ilkang Na
6262
* @author Sascha Woo
6363
* @author Christoph Strobl
64+
* @author Dmitriy Yakovlev
6465
*/
6566
public class DefaultResultMapper extends AbstractResultMapper {
6667

@@ -105,8 +106,9 @@ public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz,
105106
for (SearchHit hit : response.getHits()) {
106107
if (hit != null) {
107108
T result = null;
108-
if (!StringUtils.isEmpty(hit.getSourceAsString())) {
109-
result = mapEntity(hit.getSourceAsString(), clazz);
109+
String hitSourceAsString = hit.getSourceAsString();
110+
if (!StringUtils.isEmpty(hitSourceAsString)) {
111+
result = mapEntity(hitSourceAsString, clazz);
110112
} else {
111113
result = mapEntity(hit.getFields().values(), clazz);
112114
}

0 commit comments

Comments
 (0)