# How to perform Index Stats API using NodeClient?

**URL:** <https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 13, 2022, 8:37am UTC](https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002 "2022-06-13T08:37:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nishikant\_Tayade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishikant_tayade/32/84159_2.png) [@Nishikant\_Tayade](https://discuss.elastic.co/u/Nishikant_Tayade)\
**Post date:** [June 13, 2022, 8:37am UTC](https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002/1 "2022-06-13T08:37:59Z")

</div>

Hi,

I am using ES 7.10.2

I have come across Index Stats API in ES documentation. Also in Java Lib there is class available named

I did come across `NodeClient`, so I am trying to fetch index stats as below :

```auto
NodeClient nodeClient = new NodeClient(Settings.EMPTY, new ThreadPool(Settings.EMPTY));
				IndicesStatsRequestBuilder indicesStatsRequestBuilder = nodeClient.admin()
						.indices()
						.prepareStats("indexNameHere");
				IndicesStatsResponse indicesStatsResponse = indicesStatsRequestBuilder.get();
				System.out.println("indicesStatsResponse = " + indicesStatsResponse);

```

But I am getting `NodeClient has not been initialized` exception, what I am doing wrong ? or am I missing any steps ?

Any help is much appreciated:)

---

<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 13, 2022, 12:37pm UTC](https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002/2 "2022-06-13T12:37:59Z")

</div>

Hi @Nishikant_Tayade .

If you are not successful with the IndicesStatsRequest you can also do it as follows:

```
 Request request = new Request("GET", "/index_name/_stats");
 var response = client.getLowLevelClient().performRequest(request);
 System.out.println(EntityUtils.toString(response.getEntity()));
```

---

<div class="post-metadata">

**Author:** ![Nishikant\_Tayade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishikant_tayade/32/84159_2.png) [@Nishikant\_Tayade](https://discuss.elastic.co/u/Nishikant_Tayade)\
**Post date:** [June 13, 2022, 12:47pm UTC](https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002/3 "2022-06-13T12:47:18Z")

</div>

@RabBit_BR Thanks for reaching out !! As I can't use lowlevelclient, I did found another way to, using `NodeClient` actaully, I have updated my question.

---

<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 11, 2022, 12:47pm UTC](https://discuss.elastic.co/t/how-to-perform-index-stats-api-using-nodeclient/307002/4 "2022-07-11T12:47:48Z")

</div>

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