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')
[[["易于理解","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-09-04。"],[[["\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,["# The Document Class\n\nClass `Document` represents a document containing searchable content.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\n`Document` is defined in the module `google.appengine.api.search`.\n\nConstructor\n-----------\n\nThe constructor for class `Document` is defined as follows:\n\nclass Document(doc_id=None, fields=None, language='en', rank=None)\n\n: Construct an instance of class `Document`.\n\n The following example shows how to create a document consisting of a set of fields, some plain text and one in HTML: \n\n ```python\n from google.appengine.api import search\n\n search.Document(\n doc_id='documentId',\n fields=[search.TextField(name='subject', value='going for dinner'),\n search.HtmlField(name='body', value='\u003chtml\u003eI found a place.\u003c/html\u003e'),\n search.TextField(name='signature', value='brzydka pogoda', language='pl')],\n language='en')\n ```\n\n \u003cbr /\u003e\n\n:\n\n Arguments\n\n doc_id\n\n : The *document identifier,* a human-readable ASCII string identifying the document. Must contain no whitespace characters and not start with an exclamation point (`!`). If omitted, the search service will provide an identifier string.\n\n\n In most cases, you do not need to specify the document identifier explicitly. Specifying your own identifier is useful, however, for implementing search with other storage mechanisms, such as Blobstore or Google Storage. In the case of Blobstore, for example, you can set the document identifier to the [BlobKey](/appengine/docs/legacy/standard/python/refdocs/google.appengine.ext.blobstore.blobstore#google.appengine.ext.blobstore.blobstore.BlobKey) in order to associate that document with a specific blob.\n\n fields\n\n : An iterable collection of `Field` objects representing the content of the document.\n\n language\n\n : A two-letter [ISO 693-1](https://iso639-3.sil.org/) code for the language in which the document's field values are expressed.\n\n rank\n\n : The document's *rank,* an integer specifying the order in which it will be returned in search results. Newer documents are returned first. If not specified the rank will be set to the number of seconds since 1 January 2011 00:00:00 UTC.\n Note that when rank is used in a FieldExpression or SortExpression it is referenced as `_rank`.\n\n Result value\n\n : A new instance of class `Document`.\n\n Exceptions\n\n TypeError\n\n : A parameter has an invalid type or an unknown attribute was passed.\n\n ValueError\n\n : A parameter has an invalid value.\n\n \u003cbr /\u003e\n\n\u003cbr /\u003e\n\nProperties\n----------\n\nAn instance of class `Document` has the following properties:\n\ndoc_id\n\n: The document identifier, a human-readable ASCII string identifying the document.\n\nfields\n\n: A list of the document's [fields](/appengine/docs/legacy/standard/python/search/fieldclasses).\n\nlanguage\n\n: The two-letter [ISO 693-1](https://iso639-3.sil.org/) code for the language in which the document's field values are expressed.\n\nrank\n\n: The document's rank, an integer specifying the order in which it will be returned in search results.\n Note that when rank is used in a FieldExpression or SortExpression it is referenced as `_rank`.\n Also, if you create a SortExpression that includes rank as one of the sort keys, rank can only be sorted in\n the DESCENDING direction."]]