Skip to content

Commit c580713

Browse files
rciorbahonzakral
authored andcommitted
Make search_exists consistent with other _exists APIs
Fixes elastic#230 Thanks ncrocfer for the report!
1 parent b78cfbf commit c580713

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

elasticsearch/client/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,12 @@ def search_exists(self, index=None, doc_type=None, body=None, params=None):
12441244
:arg q: Query in the Lucene query string syntax
12451245
:arg routing: Specific routing value
12461246
"""
1247-
_, data = self.transport.perform_request('POST', _make_path(index,
1248-
doc_type, '_search', 'exists'), params=params, body=body)
1249-
return data
1247+
try:
1248+
self.transport.perform_request('POST', _make_path(index,
1249+
doc_type, '_search', 'exists'), params=params, body=body)
1250+
except NotFoundError:
1251+
return False
1252+
return True
12501253

12511254
@query_params('allow_no_indices', 'expand_wildcards', 'fields',
12521255
'ignore_unavailable', 'level')

elasticsearch/transport.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def perform_request(self, method, url, params=None, body=None):
273273
body = self.serializer.dumps(body)
274274

275275
# some clients or environments don't support sending GET with body
276-
if method == 'GET' and self.send_get_body_as != 'GET':
276+
if method in ('HEAD', 'GET') and self.send_get_body_as != 'GET':
277277
# send it as post instead
278278
if self.send_get_body_as == 'POST':
279279
method = 'POST'

0 commit comments

Comments
 (0)