Python 2.7은 지원이 종료되었으며 2026년 1월 31일에
지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 Python 2.7 애플리케이션을 배포할 수 없습니다. 기존 Python 2.7 애플리케이션은
지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다.
지원되는 최신 Python 버전으로 마이그레이션하는 것이 좋습니다.
ScoredDocument 클래스
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
ScoredDocument
클래스는 검색에서 반환된 점수가 매겨진 문서를 나타냅니다. 이 클래스는 명시적으로 빌드되지 않으며 Index.search()
의 결과로 반환됩니다.
ScoredDocument
은 google.appengine.api.search
모듈에 정의됩니다.
생성자
MatchScorer
클래스의 생성자는 다음과 같이 정의됩니다.
-
class ScoredDocument(doc_id=None, fields=None, language='en', sort_scores=None, expressions=None, cursor=None, rank=None)
검색에서 반환된 점수가 매겨진 문서를 나타냅니다.
인수
- doc_id
문서를 식별하는 표시 및 출력 가능한 ASCII 문자열입니다. '!'로 시작해서는 안 됩니다. 공백은 ID에서 제외됩니다. ID를 제공하지 않으면 검색 서비스에서 ID를 제공합니다.
- 필드
문서의 내용을 나타내는 Field 인스턴스의 반복 가능 항목입니다.
- language
필드 값에 사용된 언어의 두 글자 ISO 639.2 언어 코드입니다.
- sort_scores
정렬 평가 중에 할당된 점수 목록입니다. 각 정렬 차원이 포함됩니다. 양수 점수는 오름차순 정렬에, 음수 점수는 내림차순 정렬에 사용됩니다.
- expressions
요청된 표현식의 결과인 계산된 필드의 목록입니다.
- cursor
문서에 연결된 커서입니다.
- rank
문서 순위는 검색 결과에서 이 문서가 반환되는 순서를 지정하는 데 사용되며, 0 <= rank <= sys.maxint입니다. 지정하지 않으면 2011년 1월 1일 이후 경과된 초 수가 사용됩니다. 문서는 순서 ID 내림차순으로 반환됩니다.
결과 값
ScoredDocument
클래스의 새 인스턴스입니다.
예외
- TypeError
매개변수에 잘못된 유형이 있거나 알 수 없는 속성이 전달된 경우 발생합니다.
- ValueError
매개변수에 잘못된 값이 있는 경우 발생합니다.
속성
ScoredDocument
클래스의 인스턴스에는 다음 속성이 있습니다.
- sort_scores
API에서 검색 결과를 정렬하는 동안 할당된 점수의 목록을 반환합니다. 각 정렬 차원이 포함됩니다. 양수 점수는 오름차순 정렬에, 음수 점수는 내림차순 정렬에 사용됩니다.
- expressions
표현식을 평가한 결과인 계산된 필드의 목록입니다. 예를 들어 다음 필드 표현식의 목적은 content
필드에서 'good story'
쿼리와 일치하는 부분을 추출한 HTML 스니펫이 포함된 스니펫 필드를 계산하는 것입니다.
FieldExpression(name='snippet', 'snippet("good story", content)')
이 쿼리에 대해 API에서 반환하는 ScoredDocument.expression
은 다음과 같습니다.
HtmlField(name='snippet', value='that was a good story to finish')
- cursor
결과에 연결된 커서로서 검색 결과의 다음 집합을 반환할 시작점으로 사용됩니다. Index.cursor_type
을 Index.RESULT_CURSOR
로 설정해야 이 속성이 반환되며, 그렇지 않으면 속성이 None
으로 반환됩니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 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\u003eScoredDocument\u003c/code\u003e class represents a scored document returned from a search operation and is not manually constructed but rather received as a result from \u003ccode\u003eIndex.search()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt includes properties such as \u003ccode\u003edoc_id\u003c/code\u003e, \u003ccode\u003efields\u003c/code\u003e, \u003ccode\u003elanguage\u003c/code\u003e, \u003ccode\u003esort_scores\u003c/code\u003e, \u003ccode\u003eexpressions\u003c/code\u003e, \u003ccode\u003ecursor\u003c/code\u003e, and \u003ccode\u003erank\u003c/code\u003e which provide details about the document and its ranking.\u003c/p\u003e\n"],["\u003cp\u003eThe class allows the retrieval of scores generated during the sorting process (\u003ccode\u003esort_scores\u003c/code\u003e), computed fields from requested expressions (\u003ccode\u003eexpressions\u003c/code\u003e), and a cursor for paginated results (\u003ccode\u003ecursor\u003c/code\u003e) if configured.\u003c/p\u003e\n"],["\u003cp\u003eIf no \u003ccode\u003edoc_id\u003c/code\u003e is specified, one will be assigned by the search service.\u003c/p\u003e\n"],["\u003cp\u003eThe document's \u003ccode\u003erank\u003c/code\u003e property determines the order in which it appears in search results, with a higher \u003ccode\u003erank\u003c/code\u003e meaning the document is returned earlier in the results.\u003c/p\u003e\n"]]],[],null,["# class ScoredDocument\n\nClass `ScoredDocument` represents a scored document returned from a search. You do not build this class explicitly; rather, it is returned as a result of [Index.search()](/appengine/docs/legacy/standard/python/search/indexclass).\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`ScoredDocument` is defined in the `google.appengine.api.search` module.\n\nConstructor\n-----------\n\nThe constructor for class `MatchScorer` is defined as follows:\n\n\nclass ScoredDocument(doc_id=None, fields=None, language='en', sort_scores=None, expressions=None, cursor=None, rank=None)\n\n:\n\n Represents a scored document returned from a search.\n\n \u003cbr /\u003e\n\n:\n\n Arguments\n\n doc_id\n\n : The visible, printable ASCII string identifying the document. Must not begin with '!'. Whitespace is excluded from ids. If no id is provided, the search service will provide one.\n\n fields\n\n : An iterable of Field instances representing the content of the document.\n\n language\n\n : The two-letter [ISO 639.2 language code](http://www.loc.gov/standards/iso639-2/php/code_list.php) of the language used in the field values.\n\n sort_scores\n\n : The list of scores assigned during sort evaluation. Each sort dimension is included. Positive scores are used for ascending sorts; negative scores for descending.\n\n expressions\n\n : The list of computed fields which are the result of expressions requested.\n\n cursor\n\n : A cursor associated with the document.\n\n rank\n\n : The document rank is used to specify the order this document will be returned in search results, where 0 \\\u003c= rank \\\u003c= sys.maxint. If not specified, the number of seconds since 1st Jan 2011 is used. Documents are returned in descending order of the order ID.\n\n Result value\n\n : A new instance of class `ScoredDocument`.\n\n Exceptions\n\n TypeError\n\n : If any of the parameters have an invalid type, or an unknown attribute is passed.\n\n ValueError\n\n : If any parameter has an invalid value.\n\n \u003cbr /\u003e\n\nProperties\n----------\n\nAn instance of class `ScoredDocument` has the following properties:\n\nsort_scores\n\n: Returns the list of scores assigned while the API is sorting the results of a search. Each sort dimension is included. Positive scores are used for ascending sorts and negative scores for descending.\n\nexpressions\n\n: The list of computed fields the result of expression evaluation. For example, the following [field expression](/appengine/docs/legacy/standard/python/search/fieldexpressionclass) seeks to compute a snippet field containing HTML snippets extracted from the matching of the query `'good story'` in the `content` field:\n\n ```python\n FieldExpression(name='snippet', 'snippet(\"good story\", content)')\n ```\n Given this query, the API would return the following `ScoredDocument.expression`: \n\n ```python\n HtmlField(name='snippet', value='that was a good story to finish')\n ```\n\n \u003cbr /\u003e\n\ncursor\n\n: A cursor associated with a result used as a starting point from which to return the next set of search results. This property will not return unless you set the `Index.cursor_type` to `Index.RESULT_CURSOR`; otherwise the property returns be `None`."]]