【问题标题】:ElasticSearch error: 'The client noticed that the server is not a supported distribution of Elasticsearch'ElasticSearch 错误:'客户端注意到服务器不是 Elasticsearch 的受支持分布'
【发布时间】:2021-10-29 16:40:58
【问题描述】:

ElasticSearch 新手。我按照本指南进行设置:https://john.soban.ski/boto3-ec2-to-amazon-elasticsearch.html

我在那里运行了“connect_to_es.py”脚本,奇怪的是它第一次运行,但在随后的运行中,它开始抛出这个错误:

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

我拥有的 elasticsearch python 库版本是 7.14,而我在 AWS 上的 elasticsearch 运行的是 7.10。对这里发生的事情有什么想法吗?

代码副本:

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

【问题讨论】:

    标签: python-3.x amazon-web-services elasticsearch boto3 amazon-elasticsearch


    【解决方案1】:

    新的elasticsearch-js 有问题:

    将其降级到较低版本(例如 7.13)应该会有所帮助。

    【讨论】:

    • 原帖是关于python的,但如果你关心javascript,你可能想看看OpenSearch-JS(github上的opensearch-project/opensearch-js)。
    • elasticsearch-js 好像和 Python 没有关系
    【解决方案2】:

    好像降级修复了它pip3 install 'elasticsearch&lt;7.14.0'

    【讨论】:

    • 不幸的是,aws 服务实际上并不是 Elasticsearch。该检查是为了确保 Elasticsearch 客户端正在与正确的 Elasticsearch 通信,并且客户端期望的功能可用
    • 降级到比 7.14 低 1 个版本对我不起作用。但是到版本:7.13,它起作用了。
    【解决方案3】:

    正如其他一些答案所示,您现在可以降级,但opensearch-py 是更好的长期解决方案

    它应该是 elasticsearch-py 的替代品,并且会随着时间的推移进行更新和修补。支持OSS Elasticsearch和OpenSearch。

    【讨论】:

    • 我不知道为什么有人把它记下来,这是一个有效的答案,而且确实是我们在 AWS 中运行 Opensearch 的长期未来。
    猜你喜欢
    • 2021-10-16
    • 2022-01-22
    • 2021-11-24
    • 2011-10-23
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    相关资源
    最近更新 更多