To re-index an index using java, build a re-index request using ReindexRequestBuilder API like:
ReindexRequestBuilder reindexRequest = new ReindexRequestBuilder(client,ReindexAction.INSTANCE) .source("source_index") .destination("destination_index") .refresh(true);
After creating a request execute the request:
reindexRequest.execute();
To validate whether the request is executed or not add a validation check:
if(copy.execute().isDone()) { System.out.println("Request is executed"); }
Bingo! Your index is re-indexed.