es_drop.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:kafka-pyspark-elasticsearch-integration-test 作者: WuyangLI 项目源码 文件源码
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 #    
########
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号