问题
I'm trying to explore an elasticsearch cluster using python, and I'm new to elasticsearch. If I use Marvel/Sense, I can see the cluster's schema using GET _mapping
. Is there an equivalent way to do this in Python? If so I can see the "schema" of the cluster!
More generally, I'd like to discover programmatically all the indicies, each indices' doc_types, classify the doc_types' fields (are they text strings, ints, floats, what range to the numeric ones take, ..) basically learn the schema and basic statistics of each field. If there is a better way than GET _mapping
to start this project, I'm all ears.
This is related to this question, where they are looking for a list of indices using Python, but is more general.
回答1:
You can do that with pyelasticsearch. This is how you can do GET _mapping
in python.
From the Docs
get_mapping(index=None, doc_type=None) [source]
Fetch the mapping definition for a specific index and type.
Parameters:
index – An index or iterable thereof
doc_type – A document type or iterable thereof
Omit both arguments to get mappings for all types and indexes.
Explore API to learn more
来源:https://stackoverflow.com/questions/33748920/equivalent-of-get-mapping-marvel-sense-in-python