Skip to content

Commit 7708d99

Browse files
removed redundant setter and fixed docs
1 parent 9758f39 commit 7708d99

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/CrudIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public void testUpdateByQuery() throws IOException {
717717
{
718718
// test1: create one doc in dest
719719
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest();
720-
updateByQueryRequest.setIndices(sourceIndex);
720+
updateByQueryRequest.indices(sourceIndex);
721721
updateByQueryRequest.setQuery(new IdsQueryBuilder().addIds("1").types("type"));
722722
updateByQueryRequest.setRefresh(true);
723723
BulkByScrollResponse bulkResponse =
@@ -735,7 +735,7 @@ public void testUpdateByQuery() throws IOException {
735735
{
736736
// test2: update using script
737737
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest();
738-
updateByQueryRequest.setIndices(sourceIndex);
738+
updateByQueryRequest.indices(sourceIndex);
739739
updateByQueryRequest.setScript(new Script("if (ctx._source.foo == 2) ctx._source.foo++;"));
740740
updateByQueryRequest.setRefresh(true);
741741
BulkByScrollResponse bulkResponse =

client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public void testReindex() throws IOException {
474474

475475
public void testUpdateByQuery() throws IOException {
476476
UpdateByQueryRequest updateByQueryRequest = new UpdateByQueryRequest();
477-
updateByQueryRequest.setIndices(randomIndicesNames(1, 5));
477+
updateByQueryRequest.indices(randomIndicesNames(1, 5));
478478
Map<String, String> expectedParams = new HashMap<>();
479479
if (randomBoolean()) {
480480
updateByQueryRequest.setDocTypes(generateRandomStringArray(5, 5, false, false));

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/CRUDDocumentationIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,7 @@ public void testUpdateByQuery() throws Exception {
924924
}
925925
{
926926
// tag::update-by-query-request
927-
UpdateByQueryRequest request = new UpdateByQueryRequest(); // <1>
928-
request.setIndices("source1", "source2"); // <2>
927+
UpdateByQueryRequest request = new UpdateByQueryRequest("source1", "source2"); // <1>
929928
// end::update-by-query-request
930929
// tag::update-by-query-request-conflicts
931930
request.setConflicts("proceed"); // <1>
@@ -993,7 +992,7 @@ public void testUpdateByQuery() throws Exception {
993992
}
994993
{
995994
UpdateByQueryRequest request = new UpdateByQueryRequest();
996-
request.setIndices("source1");
995+
request.indices("source1");
997996

998997
// tag::update-by-query-execute-listener
999998
ActionListener<BulkByScrollResponse> listener = new ActionListener<BulkByScrollResponse>() {

docs/java-rest/high-level/document/update-by-query.asciidoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66

77
A `UpdateByQueryRequest` can be used to update documents in an index.
88

9-
It requires an existing index and a target index which may or may not exist pre-request.
9+
It requires an existing index (or a set of indices) on which the update is to be performed.
1010

1111
The simplest form of a `UpdateByQueryRequest` looks like follows:
1212

1313
["source","java",subs="attributes,callouts,macros"]
1414
--------------------------------------------------
1515
include-tagged::{doc-tests}/CRUDDocumentationIT.java[update-by-query-request]
1616
--------------------------------------------------
17-
<1> Creates the `UpdateByQueryRequest`
18-
<2> Adds a list of sources to update
17+
<1> Creates the `UpdateByQueryRequest` on a set of indices.
1918

2019
By default version conflicts abort the `UpdateByQueryRequest` process but you can just count them by settings it to
2120
`proceed` in the request body

server/src/main/java/org/elasticsearch/index/reindex/UpdateByQueryRequest.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public UpdateByQueryRequest() {
4848
this(new SearchRequest());
4949
}
5050

51+
public UpdateByQueryRequest(String... indices) {
52+
this(new SearchRequest(indices));
53+
}
54+
5155
UpdateByQueryRequest(SearchRequest search) {
5256
this(search, true);
5357
}
@@ -89,16 +93,6 @@ public UpdateByQueryRequest setDocTypes(String... types) {
8993
return this;
9094
}
9195

92-
/**
93-
* Set the indices on which the update by query request is to be run
94-
*/
95-
public UpdateByQueryRequest setIndices(String... indices) {
96-
if (indices != null) {
97-
getSearchRequest().indices(indices);
98-
}
99-
return this;
100-
}
101-
10296
/**
10397
* Set routing limiting the process to the shards that match that routing value
10498
*/

server/src/test/java/org/elasticsearch/index/reindex/UpdateByQueryRequestTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() {
3434
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
3535

3636
UpdateByQueryRequest request = new UpdateByQueryRequest();
37-
request.setIndices(indices);
37+
request.indices(indices);
3838
request.setIndicesOptions(indicesOptions);
3939
for (int i = 0; i < numIndices; i++) {
4040
assertEquals(indices[i], request.indices()[i]);
@@ -59,7 +59,7 @@ public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() {
5959

6060
@Override
6161
protected UpdateByQueryRequest newRequest() {
62-
return new UpdateByQueryRequest().setIndices(randomAlphaOfLength(5));
62+
return new UpdateByQueryRequest(randomAlphaOfLength(5));
6363
}
6464

6565
@Override

0 commit comments

Comments
 (0)