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
python python-2.7 elasticsearch elasticsearch-py


source to share


No one has answered this question yet

Check out similar questions:

5504
Does Python have a ternary conditional operator?
3602
Does Python have a substring method "contains"?
1293
How do I determine the type of a Python variable?
1093
What is the canonical way of type checking in Python?
815
Adding a new column to an existing DataFrame in Python pandas
645
How to find if a directory exists in Python
585
open () in Python doesn't create a file if it doesn't exist
473
Why is "not (true) in [False, True]" returning False?
18
Modifying settings and mappings on an existing index in Elasticsearch
2
Python Api to remove doc_type in Elasticsearch



All Articles
Loading...
X
Show
Funny
Dev
Pics