I would like to list all indexes present on an ElasticSearch server. I tried this:
curl -XGET localhost:9200/
but it just gives me this:
here's another way just to see the indices in the db:
curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/\n/g' | grep index | grep -v "size_in" | uniq
{ "index":"tmpdb"}
{ "index":"devapp"}
I had Kibana and ES installed on a machine. But I did not know the details(at what path, or port) was the ES node on that machine.
So how can you do it from Kibana (version 5.6)?
GET _cat/indices
I was interested in finding the the size of a particular ES index
Try
curl 'localhost:9200/_cat/indices?v'
It will give you following self explanatory output in a tabular manner
health index pri rep docs.count docs.deleted store.size pri.store.size
yellow customer 5 1 0 0 495b 495b
The simplest way to get a list of only indexes is to use the answer above, with the 'h=index' parameter:
curl -XGET "localhost:9200/_cat/indices?h=index"
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.0</version>
</dependency>
Java API
Settings settings = Settings.settingsBuilder().put("cluster.name", Consts.ES_CLUSTER_NAME).build();
TransportClient client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("52.43.207.11"), 9300));
IndicesAdminClient indicesAdminClient = client.admin().indices();
GetIndexResponse getIndexResponse = indicesAdminClient.getIndex(new GetIndexRequest()).get();
for (String index : getIndexResponse.getIndices()) {
logger.info("[index:" + index + "]");
}