我有这个脚本,可用于连接到AWS上的ElasticSearch集群以创建一些索引:
session = boto3.Session(region_name=os.environ['REGION'])
credentials = session.get_credentials()
awsauth = AWS4Auth(credentials.access_key,
credentials.secret_key,
session.region_name, 'es',
session_token=credentials.token)
es_client = Elasticsearch(
endpoint_es,
http_auth=awsauth,
use_ssl=False,
verify_certs=False,
connection_class=RequestsHttpConnection)
# Create indexes for delete test
es_client.indices.create(index='sample-index')
运行此脚本时,出现此错误:
Traceback (most recent call last):
File "test_update_02.py", line 58, in test_update_02
es_client.indices.create(index='sample-index')
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 76, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/indices.py", line 91, in create
params=params, body=body)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 318, in perform_request
status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_requests.py", line 72, in perform_request
settings = self.session.merge_environment_settings(prepared_request.url, {}, None, None, None)
AttributeError: 'Session' object has no attribute 'merge_environment_settings'
这是一个有问题的文件(第72行): https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/connection/http_requests.py
我不明白为什么会出现此错误。有任何线索吗?