问题描述
我正在尝试使用boto3和cloudsearchdomain,但在为查询建立一些可选过滤器时遇到了麻烦.这就是我所做的:
I am trying to use boto3 and cloudsearchdomain but I am having troubles establishing some optional filters over my query. This is what I did:
response = client.search(
query=query,
filterQuery= {'city':city},
partial=True,
queryOptions= {'fields':'full_address'},
queryParser='simple',
size=size)
根据boto3的文档,filterQuery参数应该是一个字符串,但是我不知道它应该具有的结构,并且我在互联网上什么也没找到. queryOptions应该是JSON,这是我要发送的内容,但是我还检索到一条错误消息,指出它应该是字符串
Based on the documentation of boto3, the filterQuery parameter should be an string, but I have no idea of the structure it should have and I found nothing on the internet. queryOptions should be a JSON, and this is what I am sending but I also retrieve an error message saying that it should be a string
ParamValidationError: Parameter validation failed:
Invalid type for parameter queryOptions, value: {'fields': 'full_address'},
type: <type 'dict'>, valid types: <type 'basestring'>
谢谢你,阿尔瓦罗
推荐答案
我终于找到了答案.我将其发布在这里,以防它可以帮助遇到类似问题的其他人:
I finally found the answer. I post it here just in case it can help other people with similar issues:
response = client.search(
query="myquery",
queryParser='simple',
partial=True,
queryOptions= '{"fields":["full_address"]}',
filterQuery='city:33044'
)
这篇关于如何在CloudSearch Boto3上使用filterQuery和queryOptions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!