[英]How to use filterQuery and queryOptions on cloudsearch boto3
I am trying to use boto3 and cloudsearchdomain but I am having troubles establishing some optional filters over my query. 我正在尝试使用boto3和cloudsearchdomain,但是在查询中建立一些可选过滤器时遇到了麻烦。 This is what I did: 这是我所做的:
response = client.search(
query=query,
filterQuery= {'city':city},
partial=True,
queryOptions= {'fields':'full_address'},
queryParser='simple',
size=size)
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. 根据boto3的文档,filterQuery参数应该是一个字符串,但是我不知道它应该具有的结构,并且在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 queryOptions应该是JSON,这是我要发送的内容,但是我还检索到一条错误消息,指出它应该是字符串
ParamValidationError: Parameter validation failed:
Invalid type for parameter queryOptions, value: {'fields': 'full_address'},
type: <type 'dict'>, valid types: <type 'basestring'>
thank you, Álvaro 谢谢阿尔瓦罗
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'
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.