try {
IndicesAdminClient iac = new ESClient().getClient().admin().indices();
OptimizeRequest req = new OptimizeRequest(indexNames.toArray(new String[indexNames.size()]));
OptimizeResponse res = iac.optimize(req).get();
Logger.info(this.getClass(), "Optimizing " + indexNames + " :" + res.getSuccessfulShards() + "/" + res.getTotalShards()
+ " shards optimized");
return true;
} catch (Exception e) {
throw new ElasticSearchException(e.getMessage());
}