diff --git a/batch-index/src/main/java/no/unit/nva/search/keybatch/KeyBasedBatchIndexHandler.java b/batch-index/src/main/java/no/unit/nva/search/keybatch/KeyBasedBatchIndexHandler.java index 8fdaf4e7c..984abc313 100644 --- a/batch-index/src/main/java/no/unit/nva/search/keybatch/KeyBasedBatchIndexHandler.java +++ b/batch-index/src/main/java/no/unit/nva/search/keybatch/KeyBasedBatchIndexHandler.java @@ -151,15 +151,13 @@ private void indexDocuments(List indexDocuments) { attempt(() -> indexBatch(indexDocuments)).orElse(this::logFailure); } - private Stream indexBatch(List indexDocuments) { - var bulkResponseStream = indexingClient.batchInsert(indexDocuments.stream()); - bulkResponseStream.forEach(response -> logger.info("Bulk response: {}", response)); - return bulkResponseStream; + private List logFailure(Failure> failure) { + logger.error("Bulk has failed: ", failure.getException()); + return List.of(); } - private Stream logFailure(Failure> failure) { - logger.error("Bulk has failed: ", failure.getException()); - return null; + private List indexBatch(List indexDocuments) { + return indexingClient.batchInsert(indexDocuments.stream()).toList(); } private boolean isValid(IndexDocument document) {