Python 2.7은 지원이 종료되었으며 2026년 1월 31일에
지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은
지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다.
지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
필드 클래스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Field
클래스는 문서 필드를 나타내는 추상 기본 클래스입니다. 이 클래스는 직접 인스턴스화할 수 없습니다. 대신에 특정 데이터 유형을 나타내는 하위 클래스 중 하나를 사용해야 합니다.
Field
은 모듈 google.appengine.api.search
에 정의됩니다.
속성
Field
클래스의 인스턴스에는 다음 속성이 있습니다.
- name
필드 이름입니다. 문자로 시작해야 하며 문자, 숫자, 밑줄(_
)로만 구성될 수 있고, 500자 이하(영문 기준)여야 합니다.
- 언어
토큰화를 지원하기 위한 2자로 된 필드 콘텐츠의 ISO 693-1 언어 코드입니다. 예를 들어, en
은 필드가 영어임을 나타냅니다. None
이면 문서의 언어 코드가 사용됩니다.
- value
필드 값입니다. 데이터 유형은 특정 하위 클래스에 따라 달라집니다.
서브클래스
Field
클래스에는 다음 서브클래스가 있습니다.
- class TextField
텍스트가 있는 필드입니다.
필드 값은 문자열 또는 유니코드 문자열이어야 합니다. 다음 예시에서는 폴란드어 콘텐츠가 포함된 signature
라는 텍스트 필드를 보여줍니다.
TextField(name='signature', value='brzydka pogoda', language='pl')
-
예외
- TypeError
제공된 값이 텍스트 문자열이 아닙니다.
- ValueError
값이 최대 허용 길이를 초과합니다.
- class HtmlField
HTML 콘텐츠가 있는 필드입니다.
필드 값은 필드의 검색 가능한 콘텐츠를 포함하는 문자열 또는 유니코드 문자열이어야 합니다. 다음 예시에서는 content
라는 HTML 필드를 보여줍니다.
HtmlField(name='content', value='<html>herbata, kawa</html>', language='pl')
-
예외
- TypeError
제공된 값이 텍스트 문자열이 아닙니다.
- ValueError
값이 최대 허용 길이를 초과합니다.
- class AtomField
색인 생성을 위해 분할할 수 없는(Atom) 토큰으로 취급되는 텍스트가 있는 필드입니다.
필드 값은 Atom 토큰으로 처리되는 문자열 또는 유니코드 객체여야 합니다. 다음 예시에서는 contributor
라는 Atom 필드를 보여 줍니다.
AtomField(name='contributor', value='foo@bar.com')
-
예외
- TypeError
제공된 값이 텍스트 문자열이 아닙니다.
- ValueError
값이 최대 허용 길이를 초과합니다.
- class NumberField
숫자 값이 있는 필드입니다.
필드 값은 숫자여야 합니다. 다음 예시에서는 정수 값이 10인 size
라는 숫자 필드를 보여 줍니다.
NumberField(name='size', value=10)
예외
- TypeError
제공된 값이 숫자가 아닙니다.
- class DateField
날짜 또는 날짜/시간 값이 있는 필드입니다.
필드의 값은 datetime.date
또는 datetime.datetime
유형이어야 합니다.
Python의 '기본' 날짜 및 시간 객체만 사용할 수 있습니다. 'Aware' 객체는 허용되지 않습니다.
다음 예시에서는 2011년 3월 21일을 나타내는 creation_date
라는 날짜 필드를 보여줍니다.
DateField(name='creation_date', value=datetime.date(2011, 03, 21))
예외
- TypeError
제공된 값이 datetime.date
또는 datetime.datetime
이 아닙니다.
- class GeoField
GeoPoint 값이 있는 필드입니다.
다음 예시에서는 위도 -33.84도 및 경도 151.26도의 위치를 나타내는 place
라는 GeoField를 보여줍니다.
GeoField(name='place', value=GeoPoint(latitude=-33.84, longitude=151.26))
예외
- TypeError
제공된 값이 GeoPoint
가 아닙니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 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\u003eField\u003c/code\u003e class is an abstract base class for document fields and should not be directly instantiated; subclasses should be used instead.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eField\u003c/code\u003e instance has properties for \u003ccode\u003ename\u003c/code\u003e, \u003ccode\u003elanguage\u003c/code\u003e, and \u003ccode\u003evalue\u003c/code\u003e, with specific constraints on the \u003ccode\u003ename\u003c/code\u003e format and the \u003ccode\u003evalue\u003c/code\u003e data type.\u003c/p\u003e\n"],["\u003cp\u003eThere are six subclasses of \u003ccode\u003eField\u003c/code\u003e: \u003ccode\u003eTextField\u003c/code\u003e, \u003ccode\u003eHtmlField\u003c/code\u003e, \u003ccode\u003eAtomField\u003c/code\u003e, \u003ccode\u003eNumberField\u003c/code\u003e, \u003ccode\u003eDateField\u003c/code\u003e, and \u003ccode\u003eGeoField\u003c/code\u003e, each designed for different data types like text, HTML, atomic tokens, numbers, dates, and geographic locations, respectively.\u003c/p\u003e\n"],["\u003cp\u003eEach subclass of \u003ccode\u003eField\u003c/code\u003e has specific data type requirements for the \u003ccode\u003evalue\u003c/code\u003e property and will raise a \u003ccode\u003eTypeError\u003c/code\u003e if an incorrect type is provided.\u003c/p\u003e\n"],["\u003cp\u003eThe different subclasses will raise \u003ccode\u003eValueError\u003c/code\u003e exceptions if the \u003ccode\u003evalue\u003c/code\u003e exceeds the maximum allowable length.\u003c/p\u003e\n"]]],[],null,["# Field Classes\n\nClass `Field` is an abstract base class representing a field of a document. This class should not be directly instantiated; instead, use one of the subclasses representing specific data types.\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`Field` is defined in the module `google.appengine.api.search`.\n\nProperties\n----------\n\nAn instance of class `Field` has the following properties:\n\nname\n\n: Name of the field. Must begin with a letter, contain only letters, digits, and underscores (`_`), and be no longer than 500 characters.\n\nlanguage\n\n: Two-letter [ISO 693-1](http://www.sil.org/iso639-3/codes.asp?order=639_1&letter=%25) language code for the field's content, to assist in tokenization. For example, `en` signifies that the field is English. If `None`, the language code of the document will be used.\n\nvalue\n\n: Value of the field. Data type varies depending on the specific subclass.\n\nSubclasses\n----------\n\nClass `Field` has the following subclasses:\n\n\nclass TextField\n\n: A field containing text.\n\n The field's value must be a string or Unicode string. The following example shows a text field named `signature` with Polish language content: \n\n ```\n TextField(name='signature', value='brzydka pogoda', language='pl')\n ```\n\n: Exceptions\n\n TypeError\n\n : Value supplied is not a text string.\n\n ValueError\n\n : Value exceeds maximum allowable length.\n\n\nclass HtmlField\n\n: A field containing HTML content.\n\n The field's value must be a string or Unicode string containing the searchable content of the field. The following example shows an HTML field named `content`: \n\n ```\n HtmlField(name='content', value='\u003chtml\u003eherbata, kawa\u003c/html\u003e', language='pl')\n ```\n\n: Exceptions\n\n TypeError\n\n : Value supplied is not a text string.\n\n ValueError\n\n : Value exceeds maximum allowable length.\n\n\nclass AtomField\n\n: A field containing text to be treated as an indivisible (atomic) token for indexing purposes.\n\n The field's value must be a string or Unicode object to be treated as an atomic token. The following example shows an atom field named `contributor`: \n\n ```\n AtomField(name='contributor', value='foo@bar.com')\n ```\n\n: Exceptions\n\n TypeError\n\n : Value supplied is not a text string.\n\n ValueError\n\n : Value exceeds maximum allowable length.\n\n\nclass NumberField\n\n: A field containing a numeric value.\n\n The field's value must be numeric. The following example shows a number field named `size` with integer value 10: \n\n ```\n NumberField(name='size', value=10)\n ```\n\n: **Exception**\n\n TypeError\n\n : Value supplied is not numeric.\n\n\nclass DateField\n\n: A field containing a date or datetime value.\n\n The field's value must be of type `datetime.date`, or `datetime.datetime`.\n Only Python [\"naive\"](https://docs.python.org/2/library/datetime.html) date and time objects can be used. \"Aware\" objects are not allowed.\n The following example shows a date field named `creation_date` representing the date 21 March 2011: \n\n ```\n DateField(name='creation_date', value=datetime.date(2011, 03, 21))\n ```\n\n:\n\n **Exception**\n\n TypeError\n\n : Value supplied is not a `datetime.date` or a `datetime.datetime`.\n\n\nclass GeoField\n\n: A field containing a [GeoPoint](/appengine/docs/legacy/standard/python/search/geopointclass) value.\n\n The following example shows a GeoField named `place` representing a location at -33.84 degrees latitude and 151.26 degrees longitude: \n\n ```\n GeoField(name='place', value=GeoPoint(latitude=-33.84, longitude=151.26))\n ```\n\n:\n\n **Exception**\n\n TypeError\n\n : Value supplied is not a [GeoPoint](/appengine/docs/legacy/standard/python/search/geopointclass)."]]