List all indices using Java rest client


  • What is the best way to get a list of all indices in Elastic Search using Java ? I am using RestHighLevelClient.
  • Also, is there a way to get only those indices that match a prefix ?

I see cat indices REST endpoint provides the capability,
cat indices API | Elasticsearch Guide [7.17] | Elastic , but I cant find any Java client example to invoke it.

I dont know if best way but works:

    var response2 = getClient().indices().getMapping(new GetMappingsRequest().indices("*"),
    var indexes2 = response2.mappings().keySet()

Try this:

new GetMappingsRequest().indices("idx_te*")

1 Like

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