Python 2.7은 지원이 종료되었으며 2026년 1월 31일에
지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은
지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다.
지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
Document 클래스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Document
클래스는 검색 가능한 내용이 포함된 문서를 나타냅니다.
Document
은 모듈 google.appengine.api.search
에 정의됩니다.
생성자
Document
클래스의 생성자는 다음과 같이 정의됩니다.
- class Document(doc_id=None, fields=None, language='en', rank=None)
Document
클래스의 인스턴스를 생성합니다.
다음 예시는 필드 집합, 일반 텍스트, 하나의 HTML로 구성된 문서를 만드는 방법을 보여줍니다.
from google.appengine.api import search
search.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 문자열입니다. 공백 문자를 포함하거나 느낌표(!
)로 시작해서는 안됩니다. 생략하면 검색 서비스에서 식별자 문자열이 제공됩니다.
대부분의 경우 문서 식별자는 명시적으로 지정할 필요가 없습니다. 하지만 Blobstore 또는 Google Storage와 같은 다른 스토리지 메커니즘으로 검색하는 경우 고유한 식별자를 지정하는 것이 유용합니다. 예를 들어 Blobstore의 경우 BlobKey
를 문서 식별자로 설정하면 특정 blob을 문서와 연결할 수 있습니다.
- fields
문서의 내용을 나타내는 반복 가능한 Field
객체의 집합입니다.
- language
문서의 필드 값을 표현한 언어로 쓰인 두 자로 된 ISO 693-1 코드입니다.
- rank
문서의 순위로, 검색결과로 반환되는 순서를 지정하는 정수입니다. 최신 문서가 먼저 반환됩니다. 지정하지 않으면 순위는 2011년 1월 1일 00:00:00 UTC 이후의 초 수로 설정됩니다.
참고로 순위가 FieldExpression 또는 SortExpression에서 사용되는 경우 _rank
로 표시됩니다.
결과 값
Document
클래스의 새 인스턴스입니다.
예외
- TypeError
매개변수가 잘못된 유형이거나 알 수 없는 속성이 전달되었습니다.
- ValueError
매개변수의 값이 잘못되었습니다.
속성
Document
클래스의 인스턴스에는 다음 속성이 있습니다.
- doc_id
문서를 식별하는 문서 식별자로서 사람이 읽을 수 있는 ASCII 문자열입니다.
- fields
문서의 필드 목록입니다.
- language
문서의 필드 값을 표현한 언어로 쓰인 두 자로 된 ISO 693-1 코드입니다.
- rank
문서의 순위로, 검색결과로 반환되는 순서를 지정하는 정수입니다.
참고로 순위가 FieldExpression 또는 SortExpression에서 사용되는 경우 _rank
로 표시됩니다.
또한 정렬 키 중 하나로 순위가 포함된 SortExpression을 만드는 경우 순위는 내림차순으로만 정렬됩니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-04(UTC)
[[["이해하기 쉬움","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-09-04(UTC)"],[[["\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."]]