例如,以下代码段发起一个请求来搜索主题中出现 first 且任何位置出现 good 的文档,最多返回 20 个文档,为每个结果返回单个文档游标,按主题降序排列,返回作者、主题和摘要字段以及摘录的字段内容。
fromgoogle.appengine.apiimportsearch...results=index.search(search.Query(# Specify the query string using the Search API's Query language.query_string='subject:first good',options=search.QueryOptions(limit=20,cursor=search.Cursor(),sort_options=search.SortOptions(expressions=[search.SortExpression(expression='subject',default_value='')],limit=1000),returned_fields=['author','subject','summary'],snippeted_fields=['content'])))...
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-20。"],[[["\u003cp\u003eThe \u003ccode\u003eQuery\u003c/code\u003e class is used to define and send search requests to an index in the search service, specifying the query string and other search parameters.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize search parameters like sort order, result limits, and cursors for pagination by using the \u003ccode\u003eQueryOptions\u003c/code\u003e class in conjunction with the \u003ccode\u003eQuery\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003equery_string\u003c/code\u003e within the \u003ccode\u003eQuery\u003c/code\u003e object represents a boolean expression used to match documents within the index, enabling complex searches.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eQuery\u003c/code\u003e class allows for the retrieval of a cursor from \u003ccode\u003eSearchResults\u003c/code\u003e to enable efficient pagination through large result sets, allowing for continued searches.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eQuery\u003c/code\u003e constructor can handle options related to facet discovery and refinements, providing advanced filtering and analysis of search results.\u003c/p\u003e\n"]]],[],null,[]]