I want to get the current Elasticsearch version through the python API. I could easily get it through a http call like
JavaScript
x
3
1
import requests
2
requests.get(http://endpoint:9200)
3
But I am wondering is there any way to get the version through the API call instead of http request to the endpoint. Like
JavaScript
1
3
1
from elasticsearch import Elasticsearch
2
es = Elasticsearch()
3
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:
JavaScript
1
4
1
from elasticsearch import Elasticsearch
2
es = Elasticsearch()
3
es.info()
4