J.Y.Wang J.Y.Wang - 5 months ago 12
Java Question

how to list all the indices' name of elasticsearch using java?

In my elasticsearch I want to get all the indices' name of the cluster. How can I do using java?
I search the internet but there's no much useful information.

Val Val
Answer

You can definitely do it with the following simple Java code:

List<IndexMetaData> indices = client.admin().cluster()
    .prepareState().get().getState()
    .getMetaData().getIndices();

The list you obtain contains the details on all the indices available in your ES cluster.

Comments