I want to get the current Elasticsearch version through the python API. I could easily get it through a http call like
import requests requests.get(http://endpoint:9200)
But I am wondering is there any way to get the version through the API call instead of http request to the endpoint. Like
from elasticsearch import Elasticsearch es = Elasticsearch()
I went through the Elasticsearch python client documentation, but couldn’t find the call that would fetch the current ES version (https://elasticsearch-py.readthedocs.org/en/master/api.html)
Advertisement
Answer
You can achieve this using the info command:
Example:
from elasticsearch import Elasticsearch es = Elasticsearch() es.info()