From 54827798dcf4c0519366d8e5b2e0819689d38e97 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Wed, 14 May 2025 13:31:25 +0200 Subject: [PATCH] Fix missing return value in ByQueryResponse. Closes #3108 Signed-off-by: Peter-Josef Meisch --- .../data/elasticsearch/client/elc/ResponseConverter.java | 4 ++++ .../elasticsearch/core/ElasticsearchIntegrationTests.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/client/elc/ResponseConverter.java b/src/main/java/org/springframework/data/elasticsearch/client/elc/ResponseConverter.java index ce7211970..ad6a44d58 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/elc/ResponseConverter.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/elc/ResponseConverter.java @@ -498,6 +498,10 @@ public ByQueryResponse byQueryResponse(UpdateByQueryResponse response) { builder.withDeleted(response.deleted()); } + if(response.updated() != null) { + builder.withUpdated(response.updated()); + } + if (response.batches() != null) { builder.withBatches(Math.toIntExact(response.batches())); } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java index bac9a9b71..98449b4cc 100755 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java @@ -1636,7 +1636,9 @@ void shouldDoUpdateByQueryForExistingDocument() { .withParams(Collections.singletonMap("newMessage", messageAfterUpdate)).withAbortOnVersionConflict(true) .build(); - operations.updateByQuery(updateQuery, IndexCoordinates.of(indexNameProvider.indexName())); + var byQueryResponse = operations.updateByQuery(updateQuery, IndexCoordinates.of(indexNameProvider.indexName())); + + assertThat(byQueryResponse.getUpdated()).isEqualTo(1); SampleEntity indexedEntity = operations.get(documentId, SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName()));