8

New to ElasticSearch. I was following this guide to get things set up: https://john.soban.ski/boto3-ec2-to-amazon-elasticsearch.html

I ran the "connect_to_es.py" script there, and oddly it worked the first time, but in a subsequent runs, it started throwing this error:

Traceback (most recent call last):
  File "../connect_to_es.py", line 21, in <module>
    print(json.dumps(es.info(), indent=4, sort_keys=True))
  File "/home/ubuntu/projects/.venv/lib/python3.8/site-packages/elasticsearch/client/utils.py", line 168, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/home/ubuntu/projects/.venv/lib/python3.8/site-packages/elasticsearch/client/__init__.py", line 294, in info
    return self.transport.perform_request(
  File "/home/ubuntu/projects/.venv/lib/python3.8/site-packages/elasticsearch/transport.py", line 413, in perform_request
    _ProductChecker.raise_error(self._verified_elasticsearch)
  File "/home/ubuntu/projects/.venv/lib/python3.8/site-packages/elasticsearch/transport.py", line 630, in raise_error
    raise UnsupportedProductError(message)
elasticsearch.exceptions.UnsupportedProductError: The client noticed that the server is not a supported distribution of Elasticsearch

The elasticsearch python library version I have is 7.14, and my elasticsearch on AWS is running 7.10. Any thoughts on what's going on here?

Copy of code:

from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
import boto3
import json

host = '<url>.us-east-1.es.amazonaws.com'
region = 'us-east-1'

service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

es = Elasticsearch(
    hosts = [{'host': host, 'port': 443}],
    http_auth = awsauth,
    use_ssl = True,
    verify_certs = True,
    connection_class = RequestsHttpConnection
)

print(json.dumps(es.info(), indent=4, sort_keys=True))
de1337ed
  • 3,113
  • 12
  • 37
  • 55
  • Thank you for pointing this out! I updated the blog post you reference: https://john.soban.ski/boto3-ec2-to-amazon-elasticsearch.html – John Sobanski Feb 20 '23 at 15:34

5 Answers5

7

Seems like downgrading fixed it pip3 install 'elasticsearch<7.14.0'

de1337ed
  • 3,113
  • 12
  • 37
  • 55
  • unfortunately the aws service is not actually Elasticsearch. that check is there to ensure that the Elasticsearch client is talking to proper Elasticsearch, and that the functionality the client expects is available – warkolm Sep 02 '21 at 05:00
  • downgrading to 1 version lesser than `7.14` did not work for me. But to version: `7.13`, it worked. – Moosa Sharieff Oct 01 '21 at 06:07
5

New elasticsearch-js has an issue:

Downgrading it to lower version (e.g. 7.13) should help.

Marcin
  • 215,873
  • 14
  • 235
  • 294
1

As some of the other answers indicate, you can downgrade right now but opensearch-py is a better long term solution

It should be a drop-in replacement for elasticsearch-py and it will be updated and patched over time. It supports OSS Elasticsearch and OpenSearch.

stockholmux
  • 1,169
  • 11
  • 24
  • I don't know why anyone has marked this down, it's a valid answer, and is indeed the long term future for any of us running Opensearch in AWS. – SamStephens Sep 22 '21 at 01:41
0

this error occurs because of the version conflict. Version of elasticsearch python library and elasticsearch should be the same.

In my case, elasticsearch version was 7.10 on AWS and I was using elasticsearch python library version 7.15 with my Django project. I removed it and installed new python library with version 7.10 in Django project and it worked fine for me.

0

I fixed the error by making following changes in Gemfile -

I changed -

gem 'elasticsearch'

to -

gem 'elasticsearch', '~> 7.1'

Ideally, I downgraded from 7.18(current version as of today) to 7.1

Milind
  • 4,535
  • 2
  • 26
  • 58