クラスタ情報とインデックス情報を取得する方法を次のコードに示します
@Test 公共 無効 testCluster()はスローIOExceptionが、InterruptedExceptionある、ExecutionExceptionを{ // 指定集群 。セッティングの設定= Settings.builder()プット( "cluster.name"、 "私のアプリケーション" ).build(); // 创建客户端 のtransportClientクライアント= 新しいPreBuiltTransportClient(設定) .addTransportAddress(新しい TransportAddress(InetAddress.getByName( "192.168.43.151")、9300 )); ClusterHealthResponse healths = client.admin()クラスター()prepareHealth())(取得。。。。 文字列のclusterName =healths.getClusterName(); // 出力クラスタ名 のSystem.out.println( "clusterNameの=" + clusterNameの); INT numberOfDataNodes = healths.getNumberOfDataNodes(); // 出力ノード番号 のSystem.out.println(「numberOfDataNodes = 「+ numberOfDataNodes); // 各インデックス情報の出力 のために。(ClusterIndexHealthヘルス:healths.getIndices()値()){ 文字列インデックス = health.getIndex(); int型 numberOfShards = health.getNumberOfShards(); int型 numberOfReplicas = ヘルス.getNumberOfReplicas()。 System.out.println( "インデックス=" +指数); // 索引名 のSystem.out.println( "numberOfShards =" + numberOfShards)。// 分片数量 のSystem.out.println( "numberOfReplicas =" + numberOfReplicas)。// 副本数量 ClusterHealthStatus clusterHealthStatus = health.getStatus()。 System.out.println( "clusterHealthStatus =" + clusterHealthStatus.toString())。// 健康状态 } client.close()。 }