use of org.springframework.data.elasticsearch.core.document.SearchDocumentResponse in project spring-data-elasticsearch by spring-projects.
the class ReactiveElasticsearchTemplate method doFindForResponse.
private <T> Mono<SearchDocumentResponse> doFindForResponse(Query query, Class<?> clazz, IndexCoordinates index) {
return Mono.defer(() -> {
SearchRequest request = requestFactory.searchRequest(query, clazz, index);
request = prepareSearchRequest(request, false);
SearchDocumentCallback<?> documentCallback = new ReadSearchDocumentCallback<>(clazz, index);
// noinspection unchecked
SearchDocumentResponse.EntityCreator<T> entityCreator = searchDocument -> ((Mono<T>) documentCallback.toEntity(searchDocument)).toFuture();
return doFindForResponse(request, entityCreator);
});
}
use of org.springframework.data.elasticsearch.core.document.SearchDocumentResponse in project spring-data-elasticsearch by spring-projects.
the class SearchHitMapping method mapInnerHits.
private Map<String, SearchHits<?>> mapInnerHits(SearchDocument searchDocument) {
Map<String, SearchHits<?>> innerHits = new LinkedHashMap<>();
Map<String, SearchDocumentResponse> documentInnerHits = searchDocument.getInnerHits();
if (documentInnerHits != null && documentInnerHits.size() > 0) {
SearchHitMapping<SearchDocument> searchDocumentSearchHitMapping = SearchHitMapping.mappingFor(SearchDocument.class, converter);
for (Map.Entry<String, SearchDocumentResponse> entry : documentInnerHits.entrySet()) {
SearchDocumentResponse searchDocumentResponse = entry.getValue();
SearchHits<SearchDocument> searchHits = searchDocumentSearchHitMapping.mapHitsFromResponse(searchDocumentResponse, searchDocumentResponse.getSearchDocuments());
// map Documents to real objects
SearchHits<?> mappedSearchHits = mapInnerDocuments(searchHits, type);
innerHits.put(entry.getKey(), mappedSearchHits);
}
}
return innerHits;
}
Aggregations