问题
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