我想列出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 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" : { }
}
}
}
_stats命令提供了通过指定所需的指标来定制结果的方法。要获得索引,查询方法如下:
GET /_stats/indices
`_stats'查询的一般格式是:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
其中的指标是
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
作为对自己的一种锻炼,我写了一个小的elasticsearch插件,提供了列出elasticsearch指数的功能,而没有任何其他信息。你可以在以下网址找到它:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/