Get all index and types' names from cluster in ElasticSearch
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.
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}'
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.