Skip to content

Commit 34c979c

Browse files
committed
Fix IndexOutOfBoundsException when try to map inner hits with no results returned
1 parent 45b4c99 commit 34c979c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/main/java/org/springframework/data/elasticsearch/core/SearchHitMapping.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
* @author Mark Paluch
4646
* @author Roman Puchkovskiy
4747
* @author Matt Gilene
48+
* @author Sascha Woo
4849
* @since 4.0
4950
*/
5051
public class SearchHitMapping<T> {
@@ -194,7 +195,7 @@ private Map<String, SearchHits<?>> mapInnerHits(SearchDocument searchDocument) {
194195
*/
195196
private SearchHits<?> mapInnerDocuments(SearchHits<SearchDocument> searchHits, Class<T> type) {
196197

197-
if (searchHits.getTotalHits() == 0) {
198+
if (searchHits == null || searchHits.isEmpty()) {
198199
return searchHits;
199200
}
200201

0 commit comments

Comments
 (0)