Python 2.7 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Python 2.7 アプリケーションをデプロイできなくなります。既存の Python 2.7 アプリケーションは、
非推奨日以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Python に移行することをおすすめします。
SortOptions クラス
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
SortExpression
クラスは、ドキュメントの多次元の並べ替えを表します。
次のコードは、ドキュメントを製品の評価の降順に並べ替えます。評価が同等の製品は、価格が低い順に並べ替えます。最大で 1,000 個のドキュメントを並べ替えます。
SortOptions(expressions=[
SortExpression(expression='rating',
direction=SortExpression.DESCENDING, default_value=0),
SortExpression(expression='price + tax',
direction=SortExpression.ASCENDING, default_value=999999.99)],
limit=1000)
SortOptions
は、google.appengine.api.search
モジュールで定義されます。
コンストラクタ
SortOptions
クラスのコンストラクタは、次のように定義されます。
- class SortOptions(expressions=None, match_scorer=None, limit=1000)
指定したオプションに従ってドキュメントを並べ替えます。
引数
- expressions
ドキュメントの多次元の並べ替えを表す SortExpression の反復可能オブジェクト。
- match_scorer
マッチ スコアラーの仕様。ドキュメントのスコアの計算で使用されるか、または SortExpression とその他の機能を組み合わせて使用されます。
- limit
スコアを計算するドキュメント数の上限。インデックスが大量に存在する場合はこの制限を設定することをおすすめします。
結果値
SortOptions
クラスの新しいインスタンス。
例外
- TypeError
いずれかのパラメータが無効なタイプであるか、不明な属性が渡されました。
- ValueError
いずれかのパラメータの値が無効です。
プロパティ
SortOptions
クラスのインスタンスには次のプロパティがあります。
- expressions
多次元の並べ替えを指定する SortExpression のリストを返します。
- match_scorer
ドキュメントのスコアの計算に使用するマッチ スコアラーを返します。
- limit
スコアを計算するドキュメント数の上限を返します。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 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\u003eSortOptions\u003c/code\u003e class enables multi-dimensional sorting of documents, leveraging \u003ccode\u003eSortExpression\u003c/code\u003e for detailed control.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSortOptions\u003c/code\u003e allows specifying sorting criteria using an iterable of \u003ccode\u003eSortExpression\u003c/code\u003e, a match scorer, and a limit on the number of documents to sort.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eSortOptions\u003c/code\u003e constructor can be configured with \u003ccode\u003eexpressions\u003c/code\u003e, \u003ccode\u003ematch_scorer\u003c/code\u003e, and \u003ccode\u003elimit\u003c/code\u003e, throwing \u003ccode\u003eTypeError\u003c/code\u003e or \u003ccode\u003eValueError\u003c/code\u003e if input is invalid.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSortExpression\u003c/code\u003e objects can define the direction of sorting, such as ascending or descending, and a default value for the sort key.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSortOptions\u003c/code\u003e properties \u003ccode\u003eexpressions\u003c/code\u003e, \u003ccode\u003ematch_scorer\u003c/code\u003e, and \u003ccode\u003elimit\u003c/code\u003e allow you to access the configured settings for sorting.\u003c/p\u003e\n"]]],[],null,["# The SortOptions Class\n\nClass `SortExpression` represents a multi-dimensional sort of Documents.\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\nThe following code shows how to sort documents based on product rating\nin descending order and then cheapest product within similarly rated\nproducts, sorting at most 1000 documents: \n\n```python\n SortOptions(expressions=[\n SortExpression(expression='rating',\n direction=SortExpression.DESCENDING, default_value=0),\n SortExpression(expression='price + tax',\n direction=SortExpression.ASCENDING, default_value=999999.99)],\n limit=1000)\n```\n\n`SortOptions` is defined in the `google.appengine.api.search` module.\n\nConstructor\n-----------\n\nThe constructor for class `SortOptions` is defined as follows:\n\n\nclass SortOptions(expressions=None, match_scorer=None, limit=1000)\n\n:\n Sort documents according to the specified options.\n\n:\n\n Arguments\n\n expressions\n\n : An iterable of SortExpression representing a multi-dimensional sort of Documents.\n\n match_scorer\n\n : A match scorer specification which may be used to score documents or in a SortExpression combined with other features.\n\n limit\n\n : The limit on the number of documents to score. It is advisable to set this limit on large indexes.\n\n Result value\n\n : A new instance of class `SortOptions`.\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 `SortOptions` has the following properties:\n\nexpressions\n\n: Returns a list of SortExpression specifying a multi-dimensional sort.\n\nmatch_scorer\n\n: Returns a match scorer used to score documents.\n\nlimit\n\n: Returns the limit on the number of documents to score."]]