Skip to content

Commit c58e3b3

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

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1472,8 +1472,7 @@ public UpdateRequestBuilder updateRequestBuilderFor(Client client, UpdateQuery q
14721472

14731473
public UpdateByQueryRequest updateByQueryRequest(UpdateQuery query, IndexCoordinates index) {
14741474

1475-
String indexName = index.getIndexName();
1476-
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(indexName);
1475+
final UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest(index.getIndexNames());
14771476
updateByQueryRequest.setScript(getScript(query));
14781477

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

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void shouldUseAllOptionsFromUpdateQuery() {
124124
assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl");
125125
}
126126

127-
@Test // #1446
127+
@Test // #1446, #2191
128128
void shouldUseAllOptionsFromUpdateByQuery() throws JSONException {
129129

130130
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()) //
@@ -154,9 +154,10 @@ void shouldUseAllOptionsFromUpdateByQuery() throws JSONException {
154154
" }" + " }" + '}';
155155

156156
// when
157-
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index"));
157+
UpdateByQueryRequest request = getRequestFactory().updateByQueryRequest(updateQuery, IndexCoordinates.of("index1", "index2"));
158158

159159
// then
160+
assertThat(request.indices()).containsExactlyInAnyOrder("index1", "index2");
160161
assertThat(request).isNotNull();
161162
assertThat(request.getSearchRequest().indicesOptions()).usingRecursiveComparison()
162163
.isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN);

0 commit comments

Comments
 (0)