Make search_exists consistent with other _exists APIs

Fixes #230 Thanks ncrocfer for the report!
This commit is contained in:
Honza Král
2015-05-18 15:50:35 +02:00
parent 481dc907ad
commit 10c36ad530
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -1244,9 +1244,12 @@ class Elasticsearch(object):
: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
try:
self.transport.perform_request('POST', _make_path(index,
doc_type, '_search', 'exists'), params=params, body=body)
except NotFoundError:
return False
return True
@query_params('allow_no_indices', 'expand_wildcards', 'fields',
'ignore_unavailable', 'level')
+1 -1
View File
@@ -273,7 +273,7 @@ class Transport(object):
body = self.serializer.dumps(body)
# some clients or environments don't support sending GET with body
if method == 'GET' and self.send_get_body_as != 'GET':
if method in ('HEAD', 'GET') and self.send_get_body_as != 'GET':
# send it as post instead
if self.send_get_body_as == 'POST':
method = 'POST'