我想列出ElasticSearch服务器上的所有索引。我试了一下:
curl -XGET localhost:9200/
但它给了我这个:
{
"ok" : true,
"status" : 200,
"name" : "El Aguila",
"version" : {
"number" : "0.19.3",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
我想要一个所有索引的列表..
curl -XGET 'http://localhost:9200/_cluster/health?水平=指数'
这将输出如下所示
{
"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
}}
_stats/ indexes给出带有索引的结果。
$ curl -XGET "localhost:9200/_stats/indices?pretty=true"
{
"_shards" : {
"total" : 10,
"successful" : 5,
"failed" : 0
},
"_all" : {
"primaries" : { },
"total" : { }
},
"indices" : {
"visitors" : {
"primaries" : { },
"total" : { }
}
}
}
要获得集群中所有索引的简明列表,请调用
curl http://localhost:9200/_aliases
这将为您提供索引及其别名的列表。
如果你想要漂亮的打印,添加pretty=true:
curl http://localhost:9200/_aliases?pretty=true
如果你的索引是old_deuteronomy和mungojerrie,结果会是这样的:
{
"old_deuteronomy" : {
"aliases" : { }
},
"mungojerrie" : {
"aliases" : {
"rumpleteazer" : { },
"that_horrible_cat" : { }
}
}
}