ブラウザーで次の URL に移動するだけで、ElasticSearch クラスターで使用可能なインデックスを取得できます。
http://elasticsearch.company.com/_aliases _ _
これにより、インデックスの配列とそのエイリアスが JSON で返されます。次に例を示します。
{
"compute-devzone1": { },
"compute-den2": { },
"compute-den1": { },
...
}
Jest でインデックスのリストを取得するには、次のコードを使用します...
HttpClientConfig config;
JestClientFactory factory;
JestClient client;
GetAliases aliases;
JestResult result;
String json;
config = new HttpClientConfig.
Builder("http://elasticsearch.company.com").
build();
aliases = new GetAliases.
Builder().
build();
factory = new JestClientFactory();
factory.setHttpClientConfig(config);
client = factory.getObject();
result = client.execute(aliases);
json = result.getJsonString();
お気に入りの JSON プロセッサを使用して からインデックスを抽出しますjson
。