Elasticsearch java客户端调用cat服务
生活随笔
收集整理的這篇文章主要介紹了
Elasticsearch java客户端调用cat服务
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
開發(fā)環(huán)境,測(cè)試環(huán)境,預(yù)發(fā)環(huán)境和生產(chǎn)環(huán)境一般相互隔離的,使用開發(fā)環(huán)境或者測(cè)試環(huán)境可以使用cat來查看索引的情況
例如:
但預(yù)防環(huán)境和測(cè)試環(huán)境是不允許訪問的,那怎么辦呢?
可以使用后臺(tái)來查看上述信息,提供界面交互。
java client如何調(diào)用cat服務(wù)呢
舉例:
Settings setting=Settings.builder().put("cluster.name", "my-cluster").build();TransportClient client=new PreBuiltTransportClient(setting); client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300));Map<String, IndexStats> stats=client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices();for(IndexStats stat:stats.values()) {System.out.println(JSON.toJSONString(stat.getTotal().getDocs()));}輸出結(jié)果
{"averageSizeInBytes":457,"count":5966,"deleted":150,"fragment":true,"totalSizeInBytes":2798548} {"averageSizeInBytes":389,"count":11030,"deleted":52,"fragment":true,"totalSizeInBytes":4316958} {"averageSizeInBytes":545,"count":3516,"deleted":144,"fragment":true,"totalSizeInBytes":1996912} {"averageSizeInBytes":5154,"count":1,"deleted":0,"fragment":true,"totalSizeInBytes":5154} {"averageSizeInBytes":394,"count":12717,"deleted":47,"fragment":true,"totalSizeInBytes":5029512} {"averageSizeInBytes":437,"count":347,"deleted":0,"fragment":true,"totalSizeInBytes":151761} {"averageSizeInBytes":393,"count":14373,"deleted":147,"fragment":true,"totalSizeInBytes":5709073} {"averageSizeInBytes":3508,"count":3,"deleted":0,"fragment":true,"totalSizeInBytes":10525} {"averageSizeInBytes":487,"count":5374,"deleted":288,"fragment":true,"totalSizeInBytes":2762143} {"averageSizeInBytes":4790,"count":2,"deleted":0,"fragment":true,"totalSizeInBytes":9581} {"averageSizeInBytes":84,"count":10000,"deleted":0,"fragment":true,"totalSizeInBytes":849464} {"averageSizeInBytes":6374,"count":1,"deleted":0,"fragment":true,"totalSizeInBytes":6374} {"averageSizeInBytes":3862,"count":2,"deleted":0,"fragment":true,"totalSizeInBytes":7724}?
轉(zhuǎn)載于:https://www.cnblogs.com/davidwang456/p/10150755.html
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的Elasticsearch java客户端调用cat服务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: elasticSearch6源码分析(1
- 下一篇: 在ElasticSearch之下(图解搜