当elastic类型不存在时,Python elasticsearch客户端返回true

时间:2015-06-03 15:43:21

标签: python python-2.7 elasticsearch elasticsearch-py

我正在尝试删除某个类型的映射但在此之前我正在检查该类型是否存在,如下面的代码所示:

def delete_mapping(self, doc_type):
    if self.elasticsearch.indices.exists_type(index='my_index', doc_type=doc_type):
        self.elasticsearch.indices.delete_mapping(index='my_index', doc_type=doc_type)

检查类型是否存在的行返回true,即使对于不存在的类型也是如此。因此,在尝试删除类型的映射时,我会在下一行中获取TypeMissingException。

当我们在ipython控制台上运行代码时,一切看起来都很好,当代码作为异步任务的一部分运行时会出现问题。这不是每次都发生,而是在QA和Production服务器上随机发生。这两个环境是我们在弹性搜索中只有两个节点的唯一环境,我们在其他环境中看不到这个问题。

我正在使用Python 2.7,elasticsearch-py 0.4.4和elasticsearch版本1.0.1,在64位Linux上有两个节点。代码作为定期芹菜任务运行。

编辑:添加了更多详细信息。

0 个答案:

没有答案