簡體   English   中英

TransientError:臨時搜索服務錯誤-Python Google App Engine搜索

[英]TransientError: Temporary search service error - Python Google App Engine Search

我正在嘗試使用較大的number_found_accuracy運行查詢並按'updated_at'字段進行排序:

order_options = search.SortOptions(
    expressions=[search.SortExpression(expression='updated_at',
                                   direction=search.SortExpression.DESCENDING)])

query_options = search.QueryOptions(
    limit=50,
    cursor=search.Cursor(),
    sort_options=order_options,
    number_found_accuracy=25000)

index = search.Index('contacts', namespace='default')
query_future = index.search_async(search.Query("", options=query_options))
contacts = query_future.get_result()

當調用get_result()時,出現以下錯誤:

文件“ /base/alloc/tmpfs/dynamic_runtimes/python27g/3b44e98ed7fbb86b/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py”,行1535,在調用 rv = self.handle_exception(請求,響應,e ) 呼叫 rv = self.router.dispatch(request,響應)文件“ /base/alloc/tmpfs/dynamic_runtimes/python27g/3b44e98ed7fbb86b/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py”,行1278,位於default_dispatcher返回route.handler_adapter(請求,響應)文件“ /base/alloc/tmpfs/dynamic_runtimes/python27g/3b44e98ed7fbb86b/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py”,行1102,在調用返回處理程序中。dispatch()文件“ / base / data / home / apps / p〜imobzi-app / 20181127t101400.414282042583891084 / modules / base_handler.py“,第72行,在dispatch super(BaseHandler,self).dispatch()File” / base / alloc / tmpfs / dynamic_ runtimes / python27g / 3b44e98ed7fbb86b / python27 / python27_lib / versions / third_party / webapp2-2.5.2 / webapp2.py“,第572行,在調度返回中self.handle_exception(e,self.app.debug)文件” / base / alloc / tmpfs / dynamic_runtimes / python27g / 3b44e98ed7fbb86b / python27 / python27_lib / versions / third_party / webapp2-2.5.2 / webapp2.py“,第570行,在分派返回方法中(* args,** kwargs)文件” / base / data / home /apps/p~imobzi-app/20181127t101400.414282042583891084/main.py“,第132行,在獲取聯系人= query_future.get_result()文件” / base / alloc / tmpfs / dynamic_runtimes / python27g / 3b44e98ed7fbb86b / python27 / python27_lib / versions /1/google/appengine/api/search/search.py​​“,第281行,在get_result中引發_ToSearchError(e)TransientError:臨時搜索服務錯誤

當查詢結果較大(此查詢返回超過50,000個結果)時,在同一查詢中使用“ number_found_accuracy”和“ sort_options”時,將發生錯誤。

如果從query_options中刪除了“ number_found_accuracy”或“ sort_options”,我可以正常得到結果,但是如果兩者都在query_options中,則會發生錯誤。

在正常情況下,我將從查詢中刪除“ number_found_accuracy”,但我需要顯示用戶的結果計數,並按updated_at字段對其進行排序。 有誰知道解決這個問題的方法? 僅當在本地/開發環境中將項目部署到服務器時,一切都會按預期工作時,才會發生這種情況。

發生此錯誤的原因之一可能是查詢的長度超過了文檔中指定的2000個字符的限制。

通過使用Document rank對索引中的文檔進行預排序,可以解決排序問題,如StackOverflow答案中所述

另請注意,根據文檔

number_found:
返回與查詢匹配的文檔的大概數量。 QueryOptions定義搜索結果的后處理。 如果QueryOptions.number_found_accuracy參數設置為100,則number_found <= 100是正確的。

由於已設置number_found_accuracy=25000 ,因此任何大小大於25000的搜索結果都是近似的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM