簡體   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