通过Java客户端的Elasticsearch统计数据不正确
我正在尝试使用JavaAPI获取一个非常大的索引的索引状态。在后台,我正在用大量数据更新同一索引 我试过了通过Java客户端的Elasticsearch统计数据不正确,java,elasticsearch,indexing,size,Java,elasticsearch,Indexing,Size,我正在尝试使用JavaAPI获取一个非常大的索引的索引状态。在后台,我正在用大量数据更新同一索引 我试过了 IndicesStatsResponse indicesStatsResponse = client.admin().indices() .prepareStats(index_name).all().execute().actionGet(); 但这并没有返回正确的大小,因为它是一个非常大的索引。然而,使用剩余的电话,我得到了正确的答案 GET /index_n
IndicesStatsResponse indicesStatsResponse = client.admin().indices()
.prepareStats(index_name).all().execute().actionGet();
但这并没有返回正确的大小,因为它是一个非常大的索引。然而,使用剩余的电话,我得到了正确的答案
GET /index_name/_stats
也许我需要使用某种侦听器机制,所以我尝试了
IndicesStatsRequest req = new IndicesStatsRequest();
req.all();
client.admin().indices().stats(req, new ActionListener<IndicesStatsResponse>()
{
@Override
public void onResponse(IndicesStatsResponse response)
{
long s = response.getIndex(indexName).getTotal().getStore().getSizeInBytes();
System.out.println(indexName + " " + s);
}
..
});
但这并没有检索到任何有用的信息
奇怪的是,当我在Eclipse中以调试模式运行它时,它工作得非常好。所以,也许有一些冲洗机制我错过了。
出路是什么?什么是elasticsearch版本?我使用的是5.4.1,非常感谢您的帮助。什么是elasticsearch版本?我使用的是5.4.1,非常感谢您的帮助。
IndicesStatsRequest req = new IndicesStatsRequest();
req.all();
ActionFuture<IndicesStatsResponse> statsResponseFeature = client.admin().indices().stats(req.clear().flush(true).refresh(true));
IndicesStatsResponse statsResponse = statsResponseFeature.get(1, TimeUnit.MINUTES);