Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check elasticsearch connection status in python

People also ask

How does Elasticsearch check connection in python?

You can check if a cluster in Elasticsearch is running with the integral requests library. Alternatively, you can use a method of Elasticsearch's library low-level client. Try this cURL rquest to check if a cluster in Elasticsearch is active.

How do I check my Elasticsearch connection?

Testing the Install Once you have Elasticsearch installed and running on your local machine, you can test to see that it's up and running with a tool like curl. By default, Elasticsearch will be running on port 9200. Typically the machine will have a name like localhost .

How do I check Elasticsearch version in Python?

OPTION 1: Check Version using Curl from Command Line In this example, Elasticsearch is running locally on the default port so our HTTP request will be to http://localhost:9200 . If Elasticsearch was running on a different server your HTTP request would take the form http://YOURDOMAIN.com:9200 .


What you can do is call ping after creating the Elasticsearch instance, like this:

es = Elasticsearch(['http://localhost:9200/'], verify_certs=True)

if not es.ping():
    raise ValueError("Connection failed")