use of org.springframework.data.elasticsearch.core.document.DocumentAdapters in project spring-data-elasticsearch by spring-projects.
the class ReactiveElasticsearchTemplate method multiGet.
@Override
public <T> Flux<MultiGetItem<T>> multiGet(Query query, Class<T> clazz, IndexCoordinates index) {
Assert.notNull(index, "Index must not be null");
Assert.notNull(clazz, "Class must not be null");
Assert.notNull(query, "Query must not be null");
DocumentCallback<T> callback = new ReadDocumentCallback<>(converter, clazz, index);
MultiGetRequest request = requestFactory.multiGetRequest(query, clazz, index);
return //
Flux.from(execute(client -> client.multiGet(request))).map(//
DocumentAdapters::from).flatMap(multiGetItem -> //
multiGetItem.isFailed() ? //
Mono.just(MultiGetItem.of(null, multiGetItem.getFailure())) : callback.toEntity(multiGetItem.getItem()).map(//
(T item) -> MultiGetItem.of(item, multiGetItem.getFailure())));
}
Aggregations