# Java API - List all indices

**URL:** https://discuss.elastic.co/t/java-api-list-all-indices/141424
**Category:** Elasticsearch
**Created:** [July 24, 2018, 4:12pm UTC](https://discuss.elastic.co/t/java-api-list-all-indices/141424 "2018-07-24T16:12:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TameemSamawi](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@TameemSamawi](https://discuss.elastic.co/u/TameemSamawi)
#### Post date: [July 24, 2018, 4:12pm UTC](https://discuss.elastic.co/t/java-api-list-all-indices/141424/1 "2018-07-24T16:12:40Z")

</div>

Up until the new REST Client, there were a couple different ways of using the Java API to list all indices:

client.admin.indices.getAliases(new GetAliasesRequest("\*")).actionGet.getAliases  
client.admin().cluster().prepareState().get().getState().getMetaData().getIndices()

The new Cluster API only allows us to update cluster settings, so the second option no longer works.

The new Alias API has both Index and Exists functionality, but returns a boolean as opposed to a search response.

Therefore both previously known ways to list all indices using the Java API no longer work on the Rest High Level Client. The only way I can think to list all indices in my cluster is to use the Low Level Rest Client, but I'd rather not have both versions of the client in my code.

Is there a way to list all indices using the Java High Level Rest Client?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 24, 2018, 4:45pm UTC](https://discuss.elastic.co/t/java-api-list-all-indices/141424/2 "2018-07-24T16:45:10Z")

</div>

> [@TameemSamawi](#):
>
> The only way I can think to list all indices in my cluster is to use the Low Level Rest Client, but I'd rather not have both versions of the client in my code.

You already have both. Just call this:

> <https://github.com/elastic/elasticsearch/blob/6.3/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java#L226-L228>

And implement what is missing for now.

---

<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: [August 21, 2018, 4:45pm UTC](https://discuss.elastic.co/t/java-api-list-all-indices/141424/3 "2018-08-21T16:45:15Z")

</div>

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