Skip to content

Commit ae66cbd

Browse files
committed
Fix updatebyquery request.
Original Pull Request #2197 Closes #2191 (cherry picked from commit f901380)
1 parent 98d1f5b commit ae66cbd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/springframework/data/elasticsearch/core/RequestFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,7 @@ public UpdateRequest updateRequest(UpdateQuery query, IndexCoordinates index) {
10921092

10931093
public UpdateByQueryRequest updateByQueryRequest(UpdateQuery query, IndexCoordinates index) {
10941094

1095-
String indexName = index.getIndexName();
1096-
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
1095+
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(index.getIndexNames());
10971096
updateByQueryRequest.setScript(getScript(query));
10981097

10991098
if (query.getAbortOnVersionConflict() != null) {

src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchERHLCIntegrationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void shouldUseAllOptionsFromUpdateQuery() {
239239
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
240240
}
241241

242-
@Test // #1446
242+
@Test // #1446, #2191
243243
void shouldUseAllOptionsFromUpdateByQuery() throws JSONException {
244244

245245
Query searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()) //
@@ -269,9 +269,10 @@ void shouldUseAllOptionsFromUpdateByQuery() throws JSONException {
269269
" }" + " }" + '}';
270270

271271
// when
272-
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index"));
272+
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index1", "index2"));
273273

274274
// then
275+
assertThat(request.indices()).containsExactlyInAnyOrder("index1", "index2");
275276
assertThat(request).isNotNull();
276277
assertThat(request.getSearchRequest().indicesOptions()).usingRecursiveComparison()
277278
.isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN);

0 commit comments

Comments
 (0)