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 を指定しない場合、検索サービスにより提供されます。
- fields
ドキュメントのコンテンツを表す、反復可能な Field インスタンス。
- language
フィールドの値で使用される言語を表す、2 文字の 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
を返します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は 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`."]]