Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Java客户端的Elasticsearch统计数据不正确_Java_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Indexing_Size - Fatal编程技术网 elasticsearch,indexing,size,Java,elasticsearch,Indexing,Size" /> elasticsearch,indexing,size,Java,elasticsearch,Indexing,Size" />

通过Java客户端的Elasticsearch统计数据不正确

通过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

我正在尝试使用JavaAPI获取一个非常大的索引的索引状态。在后台,我正在用大量数据更新同一索引

我试过了

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);