Skip to content

Instantly share code, notes, and snippets.

@luizgpsantos
Created September 15, 2014 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizgpsantos/125656e2132097184a72 to your computer and use it in GitHub Desktop.
Save luizgpsantos/125656e2132097184a72 to your computer and use it in GitHub Desktop.
listar indices java api
import java.io.IOException;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
public class Teste {
public static void main(String[] args) throws ElasticsearchException,
IOException {
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress(
"localhost", 9300));
IndicesStatsResponse clusterStateResponse = client.admin().indices()
.prepareStats().execute().actionGet();
for (String indice : clusterStateResponse.getIndices().keySet()) {
System.out.println(indice);
}
client.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment