|
3 | 3 | import logging |
4 | 4 |
|
5 | 5 | from ..transport import Transport |
6 | | -from ..exceptions import NotFoundError, TransportError |
| 6 | +from ..exceptions import TransportError |
7 | 7 | from ..compat import string_types, urlparse |
8 | 8 | from .indices import IndicesClient |
9 | 9 | from .cluster import ClusterClient |
@@ -204,11 +204,7 @@ def ping(self, params=None): |
204 | 204 | Returns True if the cluster is up, False otherwise. |
205 | 205 | `<http://www.elastic.co/guide/>`_ |
206 | 206 | """ |
207 | | - try: |
208 | | - self.transport.perform_request('HEAD', '/', params=params) |
209 | | - except NotFoundError: |
210 | | - return False |
211 | | - return True |
| 207 | + return self.transport.perform_request('HEAD', '/', params=params) |
212 | 208 |
|
213 | 209 | @query_params() |
214 | 210 | def info(self, params=None): |
@@ -299,12 +295,8 @@ def exists(self, index, doc_type, id, params=None): |
299 | 295 | for param in (index, doc_type, id): |
300 | 296 | if param in SKIP_IN_PATH: |
301 | 297 | raise ValueError("Empty value passed for a required argument.") |
302 | | - try: |
303 | | - self.transport.perform_request('HEAD', _make_path(index, doc_type, |
| 298 | + return self.transport.perform_request('HEAD', _make_path(index, doc_type, |
304 | 299 | id), params=params) |
305 | | - except NotFoundError: |
306 | | - return False |
307 | | - return True |
308 | 300 |
|
309 | 301 | @query_params('_source', '_source_exclude', '_source_include', 'fields', |
310 | 302 | 'parent', 'preference', 'realtime', 'refresh', 'routing', 'version', |
@@ -1158,53 +1150,6 @@ def delete_template(self, id, params=None): |
1158 | 1150 | return self.transport.perform_request('DELETE', _make_path('_search', |
1159 | 1151 | 'template', id), params=params) |
1160 | 1152 |
|
1161 | | - @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', |
1162 | | - 'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', |
1163 | | - 'lenient', 'lowercase_expanded_terms', 'min_score', 'preference', 'q', |
1164 | | - 'routing') |
1165 | | - def search_exists(self, index=None, doc_type=None, body=None, params=None): |
1166 | | - """ |
1167 | | - The exists API allows to easily determine if any matching documents |
1168 | | - exist for a provided query. |
1169 | | - `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-exists.html>`_ |
1170 | | -
|
1171 | | - :arg index: A comma-separated list of indices to restrict the results |
1172 | | - :arg doc_type: A comma-separated list of types to restrict the results |
1173 | | - :arg body: A query to restrict the results specified with the Query DSL |
1174 | | - (optional) |
1175 | | - :arg allow_no_indices: Whether to ignore if a wildcard indices |
1176 | | - expression resolves into no concrete indices. (This includes `_all` |
1177 | | - string or when no indices have been specified) |
1178 | | - :arg analyze_wildcard: Specify whether wildcard and prefix queries |
1179 | | - should be analyzed (default: false) |
1180 | | - :arg analyzer: The analyzer to use for the query string |
1181 | | - :arg default_operator: The default operator for query string query (AND |
1182 | | - or OR), default 'OR', valid choices are: 'AND', 'OR' |
1183 | | - :arg df: The field to use as default where no field prefix is given in |
1184 | | - the query string |
1185 | | - :arg expand_wildcards: Whether to expand wildcard expression to concrete |
1186 | | - indices that are open, closed or both., default 'open', valid |
1187 | | - choices are: 'open', 'closed', 'none', 'all' |
1188 | | - :arg ignore_unavailable: Whether specified concrete indices should be |
1189 | | - ignored when unavailable (missing or closed) |
1190 | | - :arg lenient: Specify whether format-based query failures (such as |
1191 | | - providing text to a numeric field) should be ignored |
1192 | | - :arg lowercase_expanded_terms: Specify whether query terms should be |
1193 | | - lowercased |
1194 | | - :arg min_score: Include only documents with a specific `_score` value in |
1195 | | - the result |
1196 | | - :arg preference: Specify the node or shard the operation should be |
1197 | | - performed on (default: random) |
1198 | | - :arg q: Query in the Lucene query string syntax |
1199 | | - :arg routing: Specific routing value |
1200 | | - """ |
1201 | | - try: |
1202 | | - self.transport.perform_request('POST', _make_path(index, |
1203 | | - doc_type, '_search', 'exists'), params=params, body=body) |
1204 | | - except NotFoundError: |
1205 | | - return False |
1206 | | - return True |
1207 | | - |
1208 | 1153 | @query_params('allow_no_indices', 'expand_wildcards', 'fields', |
1209 | 1154 | 'ignore_unavailable', 'level') |
1210 | 1155 | def field_stats(self, index=None, body=None, params=None): |
|
0 commit comments