from elasticsearch import Elasticsearch, helpers
def elasticsearch(index):
es = Elasticsearch(['http://localhost:80'],
sniff_on_start=True,
sniff_on_connection_fail=True,
sniff_timeout=60)
es.cluster = "bdp-es6"
data = es.count(index=index, doc_type="reptile")
print data
if data:
return data['count']
if __name__ == '__main__':
elasticsearch("test")
网友评论