elasticsearch 1.5.2版本迁移到5.4.0版本 java客户端优化索引代码该如何写?
Elasticsearch | 作者 zhudeliliang | 发布于2017年06月06日 | 阅读数:3853
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
import org.elasticsearch.client.Client;
public class ESOptimizeService {
private String[] indices;
public ESOptimizeService(String[] indices) {
this.indices = indices;
}
public boolean optimize() {
Client client = ESClient.getClient();
try {
OptimizeRequest request = new OptimizeRequest(this.indices).maxNumSegments(1);
ActionFuture<OptimizeResponse> actionFuture = client.admin().indices().optimize(request);
client.admin().indices().optimize(request);
actionFuture.actionGet();
return actionFuture.isDone();
} catch (ElasticsearchException e) {
throw new ESException(e.getMessage(), e);
}
}
}
以上是使用1.5.2版本java客户端优化索引的代码。当使用5.4.0版本的elasticsearch之后,其中以下代码报错不知道改如何写?
1 个回复
wengqiankun - es新手
赞同来自: