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

**URL:** <https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 28, 2022, 3:26am UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309 "2022-06-28T03:26:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [June 28, 2022, 3:26am UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309/1 "2022-06-28T03:26:32Z")

</div>

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

```auto
    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.

---

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [June 28, 2022, 4:36am UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309/2 "2022-06-28T04:36:39Z")

</div>

was able to somehow get the idea by this

```auto
    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");

```

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 28, 2022, 11:14am UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309/3 "2022-06-28T11:14:33Z")

</div>

Try this:

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

```

---

<div class="post-metadata">

**Author:** ![ALX\_DM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alx_dm/32/106314_2.png) [@ALX\_DM](https://discuss.elastic.co/u/ALX_DM)\
**Post date:** [June 28, 2022, 3:11pm UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309/4 "2022-06-28T15:11:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 26, 2022, 3:12pm UTC](https://discuss.elastic.co/t/new-elasticsearch-java-api-client-how-to-get-indices-settings/308309/5 "2022-07-26T15:12:08Z")

</div>

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