Equivalent of `GET _mapping` marvel/sense in Python?

五迷三道 提交于 2020-01-06 04:18:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!