List all indexes on ElasticSearch server?

前端 未结 23 1090
被撕碎了的回忆
被撕碎了的回忆 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:10

    You can also get specific index using

    curl -X GET "localhost:9200/<INDEX_NAME>"
    e.g.   curl -X GET "localhost:9200/twitter"
    You may get output like:
    {
      "twitter": {
         "aliases": { 
    
         },
         "mappings": { 
    
         },
         "settings": {
         "index": {
            "creation_date": "1540797250479",
            "number_of_shards": "3",
            "number_of_replicas": "2",
            "uuid": "CHYecky8Q-ijsoJbpXP95w",
            "version": {
                "created": "6040299"
            },
           "provided_name": "twitter"
          }
        }
      }
    }
    

    For more info

    https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html

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

    send requtest and get response with kibana,kibana is can autocomplete elastic query builder and have more tools

    look at the kibana

     GET /_cat/indices
    

    kibana dev tools

    http://localhost:5601/app/kibana#/dev_tools/console

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

    curl -XGET 'http://localhost:9200/_cluster/health?level=indices'

    This will output like below

    {
      "cluster_name": "XXXXXX:name",
      "status": "green",
      "timed_out": false,
      "number_of_nodes": 3,
      "number_of_data_nodes": 3,
      "active_primary_shards": 199,
      "active_shards": 398,
      "relocating_shards": 0,
      "initializing_shards": 0,
      "unassigned_shards": 0,
      "delayed_unassigned_shards": 0,
      "number_of_pending_tasks": 0,
      "number_of_in_flight_fetch": 0,
      "task_max_waiting_in_queue_millis": 0,
      "active_shards_percent_as_number": 100,
      "indices": {
        "logstash-2017.06.19": {
          "status": "green",
          "number_of_shards": 3,
          "number_of_replicas": 1,
          "active_primary_shards": 3,
          "active_shards": 6,
          "relocating_shards": 0,
          "initializing_shards": 0,
          "unassigned_shards": 0
        },
        "logstash-2017.06.18": {
          "status": "green",
          "number_of_shards": 3,
          "number_of_replicas": 1,
          "active_primary_shards": 3,
          "active_shards": 6,
          "relocating_shards": 0,
          "initializing_shards": 0,
          "unassigned_shards": 0
        }}
    
    0 讨论(0)
  • 2020-12-12 10:15

    I would also recommend doing /_cat/indices which gives a nice human readable list of your indexes.

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

    The _stats command provides ways to customize the results by specifying the metrics wished. To get the indices the query is as follows:

    GET /_stats/indices
    

    The general format of the _stats query is:

    /_stats
    /_stats/{metric}
    /_stats/{metric}/{indexMetric}
    /{index}/_stats
    /{index}/_stats/{metric}
    

    Where the metrics are:

    indices, docs, store, indexing, search, get, merge, 
    refresh, flush, warmer, filter_cache, id_cache, 
    percolate, segments, fielddata, completion
    

    As an exercice to myself, I've written a small elasticsearch plugin providing the functionality to list elasticsearch indices without any other information. You can find it at the following url:

    http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/

    https://github.com/iterativ/elasticsearch-listindices

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

    _stats/indices gives the result with indices.

    $ curl -XGET "localhost:9200/_stats/indices?pretty=true"
    {
      "_shards" : {
        "total" : 10,
        "successful" : 5,
        "failed" : 0
      },
      "_all" : {
        "primaries" : { },
        "total" : { }
      },
      "indices" : {
        "visitors" : {
          "primaries" : { },
          "total" : { }
        }
      }
    }
    
    0 讨论(0)
提交回复
热议问题