繁体   English   中英

如何在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参数应该是一个字符串,但是我不知道它应该具有的结构,并且在Internet上什么也找不到。 queryOptions应该是JSON,这是我要发送的内容,但是我还检索到一条错误消息,指出它应该是字符串

ParamValidationError: Parameter validation failed:
Invalid type for parameter queryOptions, value: {'fields': 'full_address'}, 
type: <type 'dict'>, valid types: <type 'basestring'>

谢谢阿尔瓦罗

我终于找到了答案。 我将其发布在此处,以防它可以帮助遇到类似问题的其他人:

response = client.search(
    query="myquery",
    queryParser='simple',
    partial=True,
    queryOptions= '{"fields":["full_address"]}',
    filterQuery='city:33044'
    )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM