Skip to content

Commit 4fa987c

Browse files
Added options for request converters
1 parent 34cbed6 commit 4fa987c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,11 @@ static Request clusterHealth(ClusterHealthRequest healthRequest) {
816816
static Request reindex(ReindexRequest reindexRequest) throws IOException {
817817
String endpoint = new EndpointBuilder().addPathPart("_reindex").build();
818818
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
819-
Params params = new Params(request);
819+
Params params = new Params(request)
820+
.withRefresh(reindexRequest.isRefresh())
821+
.withTimeout(reindexRequest.getTimeout())
822+
.withWaitForActiveShards(reindexRequest.getWaitForActiveShards());
823+
820824
if (reindexRequest.getScrollTime() != null) {
821825
params.putParam("scroll", reindexRequest.getScrollTime());
822826
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,11 @@ public void testReindex() throws IOException {
453453
String ts = randomTimeValue();
454454
reindexRequest.setScroll(TimeValue.parseTimeValue(ts, "scroll"));
455455
}
456+
if (reindexRequest.getRemoteInfo() == null && randomBoolean()) {
457+
reindexRequest.setSourceQuery(new TermQueryBuilder("foo", "fooval"));
458+
}
459+
setRandomTimeout(reindexRequest::setTimeout, ReplicationRequest.DEFAULT_TIMEOUT, expectedParams);
460+
setRandomWaitForActiveShards(reindexRequest::setWaitForActiveShards, ActiveShardCount.DEFAULT, expectedParams);
456461
expectedParams.put("scroll", reindexRequest.getScrollTime().getStringRep());
457462
Request request = RequestConverters.reindex(reindexRequest);
458463
assertEquals("/_reindex", request.getEndpoint());

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ public Self setTimeout(TimeValue timeout) {
252252
return self();
253253
}
254254

255+
/**
256+
* Timeout to wait for the shards on to be available for each bulk request?
257+
*/
258+
public Self setTimeout(String timeout) {
259+
this.timeout = TimeValue.parseTimeValue(timeout, this.timeout, getClass().getSimpleName() + ".timeout");
260+
return self();
261+
}
262+
255263
/**
256264
* The number of shard copies that must be active before proceeding with the write.
257265
*/

0 commit comments

Comments
 (0)