How to use filterQuery and queryOptions on cloudsearch boto3

强颜欢笑 提交于 2019-12-24 08:29:27

问题


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)

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'>

thank you, Álvaro


回答1:


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'
    )


来源:https://stackoverflow.com/questions/44259489/how-to-use-filterquery-and-queryoptions-on-cloudsearch-boto3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!