# Buggy code
def search_exists(self, index=None, doc_type=None, body=None, params=None):
    """
    The exists API allows to easily determine if any matching documents
    exist for a provided query.
    `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-exists.html>`_

    :arg index: A comma-separated list of indices to restrict the results
    :arg doc_type: A comma-separated list of types to restrict the results
    :arg body: A query to restrict the results specified with the Query DSL
        (optional)
    :arg allow_no_indices: Whether to ignore if a wildcard indices
        expression resolves into no concrete indices. (This includes `_all`
        string or when no indices have been specified)
    :arg analyze_wildcard: Specify whether wildcard and prefix queries
        should be analyzed (default: false)
    :arg analyzer: The analyzer to use for the query string
    :arg default_operator: The default operator for query string query (AND
        or OR), default u'OR'
    :arg df: The field to use as default where no field prefix is given in
        the query string
    :arg expand_wildcards: Whether to expand wildcard expression to concrete
        indices that are open, closed or both., default u'open'
    :arg ignore_unavailable: Whether specified concrete indices should be
        ignored when unavailable (missing or closed)
    :arg lenient: Specify whether format-based query failures (such as
        providing text to a numeric field) should be ignored
    :arg lowercase_expanded_terms: Specify whether query terms should be
        lowercased
    :arg min_score: Include only documents with a specific `_score` value in
        the result
    :arg preference: Specify the node or shard the operation should be
        performed on (default: random)
    :arg q: Query in the Lucene query string syntax
    :arg routing: Specific routing value
    """
    _, data = self.transport.perform_request(
        "POST",
        _make_path(index, doc_type, "_search", "exists"),
        params=params,
        body=body,
    )
    return data


# Traceback (elasticsearch.exceptions.NotFoundError)
es.search_exists('my_index', 'my_type', params={'q': 'my_field:bar'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 68, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py", line 1238, in search_exists
doc_type, '_search', 'exists'), params=params, body=body)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", line 86, in perform_request
self._raise_error(response.status, raw_data)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py", line 102, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.NotFoundError: TransportError(404, u'{"exists":false}')

# Fixed code
def search_exists(self, index=None, doc_type=None, body=None, params=None):
    """
    The exists API allows to easily determine if any matching documents
    exist for a provided query.
    `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-exists.html>`_

    :arg index: A comma-separated list of indices to restrict the results
    :arg doc_type: A comma-separated list of types to restrict the results
    :arg body: A query to restrict the results specified with the Query DSL
        (optional)
    :arg allow_no_indices: Whether to ignore if a wildcard indices
        expression resolves into no concrete indices. (This includes `_all`
        string or when no indices have been specified)
    :arg analyze_wildcard: Specify whether wildcard and prefix queries
        should be analyzed (default: false)
    :arg analyzer: The analyzer to use for the query string
    :arg default_operator: The default operator for query string query (AND
        or OR), default u'OR'
    :arg df: The field to use as default where no field prefix is given in
        the query string
    :arg expand_wildcards: Whether to expand wildcard expression to concrete
        indices that are open, closed or both., default u'open'
    :arg ignore_unavailable: Whether specified concrete indices should be
        ignored when unavailable (missing or closed)
    :arg lenient: Specify whether format-based query failures (such as
        providing text to a numeric field) should be ignored
    :arg lowercase_expanded_terms: Specify whether query terms should be
        lowercased
    :arg min_score: Include only documents with a specific `_score` value in
        the result
    :arg preference: Specify the node or shard the operation should be
        performed on (default: random)
    :arg q: Query in the Lucene query string syntax
    :arg routing: Specific routing value
    """
    try:
        self.transport.perform_request(
            "POST",
            _make_path(index, doc_type, "_search", "exists"),
            params=params,
            body=body,
        )
    except NotFoundError:
        return False
    return True