def exists_es_index(str_valid_index):
"""Returns if given index exists in Elasticsearch cluster"""
connection_attempts = 0
while connection_attempts < 3:
try:
es = get_es_object()
es_indices = es.indices
return es_indices.exists(index=str_valid_index)
except exceptions.ConnectionTimeout:
connection_attempts += 1
sys.exit('Elasticsearch connection timeout, exiting now...')
评论列表
文章目录