def drop_index(cnx, config):
"""Delete index
Parameters:
cnx: HTTP connection to Elastic Search
config: Some settings (including the name of the index)
"""
sys.stderr.write( "Deleting Elastic Search index %s\n" % config.index)
####################################
cnx.request("DELETE",config.index) #
####################################
resp=cnx.getresponse()
sys.stderr.write( resp.read()+"\n")
if resp.status == httplib.NOT_FOUND:
sys.stderr.write( " WARNING: Index %s does not exist - cannot delete\n" % config.index)
elif resp.status != httplib.OK:
raise Exception(" ERROR when deleting " + config.index + ": %d %s" % (resp.status, resp.reason))
else:
sys.stderr.write( " Index deleted\n")
########
# MAIN #
########
es_drop.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录