I am unable to connect with elastic using python client
The code which run with no issue is from elasticsearch import Elasticsearch es = Elasticsearch(['http://<your_ip_address>:<your_port>'])
(I use my ip and port which is running correctly in browser)
but when I run response = es.cluster.health()
I get
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch_sync\client\utils.py", line 414, in wrapped
return api(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch_sync\client\cluster.py", line 464, in health
return self.perform_request( # type: ignore[return-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch_sync\client_base.py", line 389, in perform_request
return self._client.perform_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch_sync\client_base.py", line 331, in perform_request
raise UnsupportedProductError(
elasticsearch.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product
The error is suggesting you're not connecting to an Elasticsearch server. Have you double checked your host and post settings in your initialization?
Are you making use of OpenSearch at all? Can you share which version of the Python client you are using and which version of Elasticsearch you are trying to connect to?
OpenSearch/OpenDistro are AWS run products and differ from the original Elasticsearch and Kibana products that Elastic builds and maintains. You may need to contact them directly for further assistance.
(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns )
Thanks for confirming. Given the version of Elasticsearch you are trying to connect to, I would recommend trying version 7 of the Elasticsearch Python client as from the docs given we don't guarantee full backward compatibility:
Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.
Let us know if the alternative version fixes the problem.
You need to share the entire response, there are more information in the response, what you shared is not enough, you need to share the build_ fields from the response.
If version 7.9 of the client works, you are probably using the oss version, you can check it looking at the value of build_flavor when you the curl mentioned before.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.