From 66561136c2c334c9a42d419d0f65bd40e9d02857 Mon Sep 17 00:00:00 2001 From: Honza Kral Date: Fri, 12 Jul 2013 17:25:06 +0200 Subject: [PATCH] Ping endpoint --- elasticsearch/client/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index a15d6b9e..94ad9b82 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -1,5 +1,5 @@ from ..transport import Transport -from ..exceptions import NotFoundError +from ..exceptions import NotFoundError, TransportError from .indices import IndicesClient from .cluster import ClusterClient from .utils import query_params, _make_path @@ -56,6 +56,15 @@ class Elasticsearch(object): self.indices = IndicesClient(self) self.cluster = ClusterClient(self) + @query_params() + def ping(self, params=None): + """ Returns True if the cluster is up, False otherwise. """ + try: + self.transport.perform_request('HEAD', _make_path(), params=params) + except TransportError: + return False + return True + @query_params() def info(self, params=None): """ Get the basic info from the current cluster. """