Skip to content

Commit

Permalink
fixing stream
Browse files Browse the repository at this point in the history
  • Loading branch information
truhacevkir committed Oct 30, 2023
1 parent 3b35b1c commit 13ad442
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,13 @@ private void indexDocuments(List<IndexDocument> indexDocuments) {
attempt(() -> indexBatch(indexDocuments)).orElse(this::logFailure);
}

private Stream<BulkResponse> indexBatch(List<IndexDocument> indexDocuments) {
var bulkResponseStream = indexingClient.batchInsert(indexDocuments.stream());
bulkResponseStream.forEach(response -> logger.info("Bulk response: {}", response));
return bulkResponseStream;
private List<BulkResponse> logFailure(Failure<List<BulkResponse>> failure) {
logger.error("Bulk has failed: ", failure.getException());
return List.of();
}

private Stream<BulkResponse> logFailure(Failure<Stream<BulkResponse>> failure) {
logger.error("Bulk has failed: ", failure.getException());
return null;
private List<BulkResponse> indexBatch(List<IndexDocument> indexDocuments) {
return indexingClient.batchInsert(indexDocuments.stream()).toList();
}

private boolean isValid(IndexDocument document) {
Expand Down

0 comments on commit 13ad442

Please sign in to comment.