List all indexes on ElasticSearch server?

前端 未结 23 1088
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 09:55

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:

相关标签:
23条回答
  • 2020-12-12 10:23

    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"}
    
    0 讨论(0)
  • 2020-12-12 10:24

    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)?

    • Go to Dev Tools
    • See Console section, and run the following query:

    GET _cat/indices

    I was interested in finding the the size of a particular ES index

    0 讨论(0)
  • 2020-12-12 10:25

    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
    
    0 讨论(0)
  • 2020-12-12 10:25

    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"
    
    0 讨论(0)
  • 2020-12-12 10:26
    <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 + "]");
    }
    
    0 讨论(0)
提交回复
热议问题