New elasticsearch-java api client: how to get indices settings

Lets say we get the index replica count, how to do it using the new elasticsearch-java api client.

In raw form, I will just do

GET /my-index-000001/_settings

In HLRC, I do it like this

    final GetSettingsRequest request = new GetSettingsRequest().indices(indexName);
    final GetSettingsResponse response;
    try {
      response = client.indices().getSettings(request, RequestOptions.DEFAULT);
    } catch (final IOException e) {
      throw new UncheckedIOException(e);
    }

I am at lost on how to do this in the new elasticsearch-java api client.

Any help is appreciated.

was able to somehow get the idea by this

    GetIndicesSettingsRequest request = GetIndicesSettingsRequest.of(b->b.index(indexName));
    GetIndicesSettingsResponse response;
    try {
      response = client2.indices().getSettings(request);
    } catch (final IOException e) {
      throw new UncheckedIOException(e);
    }
    IndexState state = response.get("no_of_replica");

Try this:

System.out.println(response.get("idx_name").settings().index().numberOfReplicas());
System.out.println(response.get("idx_name").settings().index().numberOfShards());

nice, thanks, this is so helpful, appreciate it very much

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.