fromgoogle.appengine.apiimportsearchsearch.Document(doc_id='documentId',fields=[search.TextField(name='subject',value='going for dinner'),search.HtmlField(name='body',value='<html>I found a place.</html>'),search.TextField(name='signature',value='brzydka pogoda',language='pl')],language='en')
引數
doc_id
「文件識別碼」,為使用者可判讀的 ASCII 字串,用於識別文件。不得包含空白字元,且開頭不得為驚嘆號 (!)。如果省略,搜尋服務會提供 ID 字串。
在大多數情況下,您不需要明確指定文件識別碼,但在實作其他儲存機制 (例如 Blobstore 或 Google Storage) 的搜尋功能時,指定自訂識別碼會很實用。以 Blobstore 為例,您可以將文件 ID 設為 BlobKey,建立該文件與特定 blob 的關聯。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-11 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eDocument\u003c/code\u003e class represents a searchable document and is defined within the \u003ccode\u003egoogle.appengine.api.search\u003c/code\u003e module.\u003c/p\u003e\n"],["\u003cp\u003eYou can construct a \u003ccode\u003eDocument\u003c/code\u003e instance by specifying a \u003ccode\u003edoc_id\u003c/code\u003e, an iterable collection of \u003ccode\u003eField\u003c/code\u003e objects, the language of the document, and an optional rank for search result ordering.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edoc_id\u003c/code\u003e is a unique identifier for the document, and if not provided, the search service will automatically assign one.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003erank\u003c/code\u003e property determines the document's order in search results, with newer documents returned first, and if not specified, defaults to seconds since January 1, 2011.\u003c/p\u003e\n"],["\u003cp\u003eThe document language can be defined by the use of a two-letter \u003ca href=\"https://iso639-3.sil.org/\"\u003eISO 693-1\u003c/a\u003e code.\u003c/p\u003e\n"]]],[],null,[]]