Como obter todos os índices com o cliente de descanso de alto nível da Elastic?

Eu quero uma maneira agradável, rápida e fácil de obter todos os índices na pesquisa elástica usando oCliente Java REST. Atualmente, sou capaz de fazer isso agarrando seu cliente de nível inferior, assim:

public void fetchIndices() throws IOException {
    List<String> indices = null;

    RestClient restClient = client.getLowLevelClient();
    Response response = null;
    try {
        response = restClient.performRequest("GET", "/_cat/indices?v");
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, e.toString(), e);
    }

    InputStream inputStream = null;
    if (response != null) {
        try {
            inputStream = response.getEntity().getContent();
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, e.toString(), e);
        }
    }

    if (inputStream != null) {
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

        indices = new ArrayList<>();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            // Get tokens with no whitespace
            String[] tokens = line.split("\\s+");
            for (String token : tokens) {
                // TODO - make the startsWith() token configurable
                if (token.startsWith(SOME_TOKEN)) {
                    LOGGER.log(Level.INFO, "Found elasticsearch index " + token);
                    indices.add(token);
                    break;
                }
            }
        }
    }

    // Only update if we got data back from our REST call
    if (indices != null) {
        this.indices = indices;
    }
}

Basicamente, eu apenas chamo o/_cat/indices?v ponto finalconforme recomendado nos documentos. Isso funciona bem, mas eu queria saber se havia uma maneira melhor de fazer isso usando a API Java. Não consigo encontrar uma maneira em sua API atual, mas me pergunto se alguém sabe algo que eu não. Ter que trabalhar comInputStreamse os váriosReaders não é necessariamente terrível, mas apenas deseja limpar a análise de string hacky.

questionAnswers(2)

yourAnswerToTheQuestion