如何使用 Python boto3 库查询 AWS CloudSearch 域?

RTF*_*RTF 4 python amazon-web-services amazon-cloudsearch boto3

我正在尝试使用 boto3 以文档为指导查询我的 CloudSearch 域:http ://boto3.readthedocs.io/en/latest/reference/services/cloudsearchdomain.html#client

import boto3
import json

boto3.setup_default_session(profile_name='myprofile')
cloudsearch = boto3.client('cloudsearchdomain')

response = cloudsearch.search(
    query="(and name:'foobar')",
    queryParser='structured',
    returnFields='address',
    size=10
)
print( json.dumps(response) )
Run Code Online (Sandbox Code Playgroud)

...但它失败了:

botocore.exceptions.EndpointConnectionError:无法连接到端点 URL:“ https://cloudsearchdomain.eu-west-1.amazonaws.com/2013-01-01/search

但是我应该如何设置或配置我想要连接的端点或域?我尝试向endpoint请求添加一个参数,认为这可能是文档中的一个意外遗漏,但我收到了以下错误响应:

输入中的未知参数:“端点”,必须是以下之一:光标、expr、facet、filterQuery、highlight、partial、query、queryOptions、queryParser、return、size、sort、start、stats

文档说:

提交搜索请求的端点是特定于域的。您向域的搜索端点提交搜索请求。要获取域的搜索终端节点,请使用 Amazon CloudSearch 配置服务 DescribeDomains 操作。域的终端节点也显示在 Amazon CloudSearch 控制台的域控制面板上。

我知道我的搜索端点是什么,但我如何提供它?

RTF*_*RTF 7

我在 Google 论坛上找到了一个带有答案的帖子。您必须将endpoint_url参数添加到客户端构造函数中,例如

client = boto3.client('cloudsearchdomain', endpoint_url='http://...')
Run Code Online (Sandbox Code Playgroud)

我希望这些文档得到更新,因为我在弄清楚之前浪费了很多时间。