如何在 cloudsearch boto3 上使用 filterQuery 和 queryOptions
How to use filterQuery and queryOptions on cloudsearch boto3
我正在尝试使用 boto3 和 cloudsearchdomain,但我在为我的查询建立一些可选过滤器时遇到了问题。这就是我所做的:
response = client.search(
query=query,
filterQuery= {'city':city},
partial=True,
queryOptions= {'fields':'full_address'},
queryParser='simple',
size=size)
根据boto3的文档,filterQuery参数应该是一个字符串,但是我不知道它应该有什么结构,在网上也没有找到。 queryOptions 应该是 JSON,这就是我要发送的内容,但我还检索到一条错误消息,指出它应该是一个字符串
ParamValidationError: Parameter validation failed:
Invalid type for parameter queryOptions, value: {'fields': 'full_address'},
type: <type 'dict'>, valid types: <type 'basestring'>
谢谢,
阿尔瓦罗
我终于找到了答案。我 post 在这里只是为了以防万一它可以帮助其他有类似问题的人:
response = client.search(
query="myquery",
queryParser='simple',
partial=True,
queryOptions= '{"fields":["full_address"]}',
filterQuery='city:33044'
)
我正在尝试使用 boto3 和 cloudsearchdomain,但我在为我的查询建立一些可选过滤器时遇到了问题。这就是我所做的:
response = client.search(
query=query,
filterQuery= {'city':city},
partial=True,
queryOptions= {'fields':'full_address'},
queryParser='simple',
size=size)
根据boto3的文档,filterQuery参数应该是一个字符串,但是我不知道它应该有什么结构,在网上也没有找到。 queryOptions 应该是 JSON,这就是我要发送的内容,但我还检索到一条错误消息,指出它应该是一个字符串
ParamValidationError: Parameter validation failed:
Invalid type for parameter queryOptions, value: {'fields': 'full_address'},
type: <type 'dict'>, valid types: <type 'basestring'>
谢谢, 阿尔瓦罗
我终于找到了答案。我 post 在这里只是为了以防万一它可以帮助其他有类似问题的人:
response = client.search(
query="myquery",
queryParser='simple',
partial=True,
queryOptions= '{"fields":["full_address"]}',
filterQuery='city:33044'
)