简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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