Ответ 1
То, что вы называете "тип", на самом деле является "типом сопоставления", а способ его получения - просто:
curl -XGET localhost:9200/_all/_mapping
Теперь, поскольку вам нужны только имена типов сопоставления, вам не нужно ничего устанавливать, так как вы можете просто использовать Python, чтобы получить только то, что вы хотите от этого предыдущего ответа:
curl -XGET localhost:9205/_all/_mapping | python -c 'import json,sys; indices=json.load(sys.stdin); indices = [type for index in indices for type in indices.get(index).get("mappings")]; print list(indices);'
Python script делает что-то очень простое, т.е. выполняет итерацию по всем индексам и типам отображения и извлекает только последние имена:
import json,sys;
resp = json.load(sys.stdin);
indices = [type for index in resp for type in indices.get(index).get("mappings")];
print list(indices);'
UPDATE
Поскольку вы используете Ruby, тот же трюк доступен с помощью кода Ruby:
curl -XGET localhost:9205/_all/_mapping | ruby -e "require 'rubygems'; require 'json'; resp = JSON.parse(STDIN.read); resp.each { |index, indexSpec | indexSpec['mappings'].each {|type, fields| puts type} }"
Ruby script выглядит следующим образом:
require 'rubygems';
require 'json';
resp = JSON.parse(STDIN.read);
resp.each { |index, indexSpec |
indexSpec['mappings'].each { |type, fields|
puts type
}
}