Reputation: 1228
I have my cluster and I want to know all indexes and types' names in it. I use Sense.
Upvotes: 45
Views: 68683
Reputation: 71
To get all the mappings inside index:
GET /{index_name}/_search?size=50
{
"query": {
"match_all": {}
}
}
Upvotes: 0
Reputation: 3173
Some mappings are too large to efficiently use the _mapping
to parse out types. Instead consider an aggregation. Would likely be much faster. For indexes:
curl -XGET "http://localhost:9200/_search" -d'
{
"aggs": {
"indicesAgg": {
"terms": {
"field": "_index",
"size": 200
}
}
},
"size": 0
}'
And for types for a specific index (or to get all types across all indexes, simply exclude the index name {myIndex} in the url):
curl -XGET "http://localhost:9200/myIndex/_search" -d'
{
"aggs": {
"typesAgg": {
"terms": {
"field": "_type",
"size": 200
}
}
},
"size": 0
}'
I'm sure you could write a single agg to return both as well.
Upvotes: 17
Reputation: 3099
curl -XGET 'http://localhost:9200/_cat/indices?v'
will give you all the indexes.
curl -XGET 'http://localhost:9200/_mapping?pretty=true'
will give you the document types in these indexes, together with their mappings.
Upvotes: 96
Reputation: 53496
The answer by yvespeirsman is correct but if you want to just see types for indexes you can use jq to get a more compact answer.
curl -s -XGET 'http://localhost:9200/_mapping' | jq 'to_entries | .[] | {(.key): .value.mappings | keys}'
Upvotes: 33