|
22 | 22 | import java.util.Map;
|
23 | 23 | import java.util.stream.Collectors;
|
24 | 24 |
|
25 |
| -import org.apache.commons.logging.Log; |
26 |
| -import org.apache.commons.logging.LogFactory; |
| 25 | +import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; |
27 | 26 | import org.springframework.data.elasticsearch.backend.elasticsearch7.document.SearchDocumentResponse;
|
28 | 27 | import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
29 | 28 | import org.springframework.data.elasticsearch.core.document.Document;
|
|
45 | 44 | * @author Mark Paluch
|
46 | 45 | * @author Roman Puchkovskiy
|
47 | 46 | * @author Matt Gilene
|
| 47 | + * @author Sascha Woo |
48 | 48 | * @since 4.0
|
49 | 49 | */
|
50 | 50 | public class SearchHitMapping<T> {
|
51 | 51 |
|
52 |
| - private static final Log LOGGER = LogFactory.getLog(SearchHitMapping.class); |
53 |
| - |
54 | 52 | private final Class<T> type;
|
55 | 53 | private final ElasticsearchConverter converter;
|
56 | 54 | private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
@@ -194,7 +192,7 @@ private Map<String, SearchHits<?>> mapInnerHits(SearchDocument searchDocument) {
|
194 | 192 | */
|
195 | 193 | private SearchHits<?> mapInnerDocuments(SearchHits<SearchDocument> searchHits, Class<T> type) {
|
196 | 194 |
|
197 |
| - if (searchHits.getTotalHits() == 0) { |
| 195 | + if (searchHits.isEmpty()) { |
198 | 196 | return searchHits;
|
199 | 197 | }
|
200 | 198 |
|
@@ -239,7 +237,7 @@ private SearchHits<?> mapInnerDocuments(SearchHits<SearchDocument> searchHits, C
|
239 | 237 | searchHits.getSuggest());
|
240 | 238 | }
|
241 | 239 | } catch (Exception e) {
|
242 |
| - LOGGER.warn("Could not map inner_hits", e); |
| 240 | + throw new UncategorizedElasticsearchException("Unable to convert inner hits.", e); |
243 | 241 | }
|
244 | 242 |
|
245 | 243 | return searchHits;
|
|
0 commit comments