MatchScorer クラス
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
クラス
MatchScorer
を使用すると、クエリの一致の質に基づいてドキュメントの並べ替えができます。スコアラーは、ドキュメント内の用語の出現頻度に基づいてスコアを割り当てます。
MatchScorer
を使用するには、次のコードのように SortOptions
に追加します。
sort_opts = search.SortOptions(match_scorer=search.MatchScorer())
このコードは、スコアの降順で文書を並べ替えます。スコアは正の数になります。
昇順で並べ替えるには、次のコードを使用します。
sort_opts = search.SortOptions(match_scorer=search.MatchScorer(),
expressions=[search.SortExpression(
expression='_score', direction=search.SortExpression.ASCENDING,
default_value=0.0)])
この場合のスコアは負の値です。
MatchScorer
は、google.appengine.api.search
モジュールで定義されます。
コンストラクタ
MatchScorer
クラスのコンストラクタは、次のように定義されます。
- class MatchScorer()
ドキュメント内の出現頻度に基づいて検索結果にドキュメントのスコアを割り当て、クエリの一致状況を表します。
結果値
MatchScorer
クラスの新しいインスタンス。
例外
- TypeError
いずれかのパラメータが無効なタイプであるか、不明な属性が渡されました。
- ValueError
いずれかのパラメータの値が無効です。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-03-06 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-03-06 UTC。"],[[["The `MatchScorer` class allows sorting of documents based on the quality of their match to a query by assigning a score based on term frequency."],["Adding `MatchScorer` to `SortOptions` sorts documents in descending score order, resulting in positive scores."],["To sort in ascending order, use `MatchScorer` within `SortOptions` with a `SortExpression` set to `ASCENDING`, which results in negative scores."],["The `MatchScorer` class is in the `google.appengine.api.search` module, and if an invalid type or value is passed as parameters, a `TypeError` or `ValueError` will be raised."]]],[]]