Problem of connecting python client with elasticsearch

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

Hi @waqar_jamali,

Welcome to the community!

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 :elasticheart: )

Hi @carly.richmond
Here is the version of my elastic "7.10.2"
and Elasticsearch python version Elasticsearch Python client version: (8, 6, 2)

The 'import request' is working fine

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.

1 Like

But it is the Elastic distribution or the OSS?

What is the result of curl http://your-ip:your-port ?

If I'm not wrong, the Elastic python client does not work with the OSS distribution anymore in the latests releases.

Hi @leandrojmp
The curl response is

"version" : {
    "number" : "7.10.2",
   .
   .
   .
    "lucene_version" : "8.7.0",
    .

  },
  "tagline" : "You Know, for Search"

Run a curl to your elasticsearch and paste the results.

curl http://your-elastic-ip:your-elastic-port

1 Like

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.

1 Like

Thank you version 7.9.0 working

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.

It is "default"

Weird, it should've work then since 7.10.2 uses the basic license.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.