我可以使用clean index和Bearer token的URI在Postman中查询ES。我有以下代码来测试从Python查询:
from elasticsearch import Elasticsearch
...
token = response['access_token']
url = 'https://cleanindex.staging.xyz.com/'
es = Elasticsearch(
hosts=[{'host': url, 'port': 9200, 'scheme':'https'}],
basic_auth=('bearer_auth', token),
request_timeout=10,
verify_certs=False
)
字符串
当我尝试执行查询测试时,我得到一个连接错误:
# Perform a query
index = 'staging_index/_search'
query = {
'query': {
'match': {
'field_name': 'search_term',
},
}
}
try:
results = es.search(index=index, body=query,timeout=5)
except Exception as e:
print(e)
型
连接错误原因:ConnectionError(连接错误原因:NameResolutionError(<urllib3.connection.HTTPSConnection object at 0x000002102BCD4A60>:未能解析“https://cleanindex.staging.xyz.com/”([Errno 11001] getaddrinfo failed)
如何解决此错误?
附加错误:
x1c 0d1x的数据
1条答案
按热度按时间mbyulnm01#
您应该按照文档中的描述进行操作,不指定
hosts
参数,而只是将完整的URL作为第一个参数:字符串