title: check elasticsearch connection status in python
body: <p>I am trying to connect elasticsearch in my local and I wonder how can I know the connection is successful or failed before continue to process:
  I wish it is possible with the way below I used but not(it returns too many values but all useless):</p>
  
  <pre><code>try:
      es = Elasticsearch(['http://localhost:9200/'], verify_certs=True)
  except Exception as err:
      if "Connection refused" in err.message:
          logging.error("Connection failed")
  </code></pre>
  
  <p>I hope there is a way to check connection status like this:</p>
  
  <pre><code>if es == false:
      raise ValueError("Connection failed")
  </code></pre>