I'm using the ElasticSeach highlevel rest api client to do some custom reindexing from another cluster.
ReindexRequest reindexRequest = new ReindexRequest()
.setMaxDocs(3000)
.setDestIndex("my-new-index")
.setTimeout(TimeValue.timeValueHours(1))
.setRemoteInfo(
new RemoteInfo("http", "otherhost", 9200, "/",
new BytesArray(selectQuery.toString()), "user",
"password",
Map.of()), TimeValue.timeValueSeconds(30),
TimeValue.timeValueSeconds(30)))
.setSourceIndices("old-index")
.setScript(new Script(ScriptType.STORED, null, "add_sc_id", Map.of("sc_id", some-id)));
TaskSubmissionResponse task = esClient.submitReindexTask(reindexRequest, RequestOptions.DEFAULT);
I periodically check the task to see if it's done or not using the task API
Optional<GetTaskResponse> getTaskResponse =
esClient.tasks().get(new GetTaskRequest(nodeId, taskId), RequestOptions.DEFAULT);
Using this, I can see if the task is completed with getTaskResponse.get().isCompleted()
but I don't see anyway to check if it's successful or not.
By doing the GET _taks/nodeId:taskId
with curl, I see there is a response.failures
field.
Is there a way to retrieve this field with the Java High level rest api client? Or is there another way to achieve this?