Python elasticsearch client returns true if type doesn't exist

I'm trying to remove a type mapping, but before doing this, I check if the type exists as in the code below:

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)

      

The string that checks if the type exists will return true, even for a non-existent type. So I get a TypeMissingException on the next line when I try to remove the type mapping.

When we run the code in the ipython console everything looks good, the problem occurs when the code is run as part of an async task. This does not happen every time, but randomly on the QA and Production servers. These two environments are the only ones in which we have two nodes to search for elasticsearch, we don't see problems in other environments.

I am working with Python 2.7, elasticsearch-py 0.4.4 and elasticsearch version 1.0.1 with two nodes on 64 bit Linux. The code runs as a periodic celery task.

EDIT: Added more information about the issue.

+3


source to share





All Articles