use of org.springframework.data.elasticsearch.BulkFailureException in project spring-data-elasticsearch by spring-projects.
the class ReactiveElasticsearchTemplate method checkForBulkOperationFailure.
protected Mono<BulkResponse> checkForBulkOperationFailure(BulkResponse bulkResponse) {
if (bulkResponse.hasFailures()) {
Map<String, String> failedDocuments = new HashMap<>();
for (BulkItemResponse item : bulkResponse.getItems()) {
if (item.isFailed()) {
failedDocuments.put(item.getId(), item.getFailureMessage());
}
}
BulkFailureException exception = new BulkFailureException("Bulk operation has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages [" + failedDocuments + ']', failedDocuments);
return Mono.error(exception);
} else {
return Mono.just(bulkResponse);
}
}
Aggregations