Python 2.7 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、Python 2.7 アプリケーションをデプロイできなくなります。既存の Python 2.7 アプリケーションは、
非推奨日以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの Python に移行することをおすすめします。
FieldExpression クラス
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
FieldExpression
クラスを使用すると、検索結果ごとにカスタマイズされたコンテンツのスニペットを計算できます。
FieldExpression
は、google.appengine.api.search
モジュールで定義されます。
コンストラクタ
FieldExpression
クラスのコンストラクタは、次のように定義されます。
-
class FieldExpression(name, expression)
クラス FieldExpression
のインスタンスを作成します。
例:
FieldExpression(name='content_snippet',
expression='snippet("very important", content)')
各検索結果を使用して計算された content-snippet
フィールドを返すフィールド式を作成します。このフィールドには、クエリ "very
important"
に一致する content
フィールドの HTML スニペットが含まれています。
引数
- name
計算されたフィールドの名前。
- expression
評価して返す式。
結果値
FieldExpression
クラスの新しいインスタンス。
例外
- TypeError
パラメータの型が無効であるか、不明な属性が渡されました。
- ValueError
パラメータの値が無効です。
特性
FieldExpression
クラスのインスタンスには次のプロパティがあります。
- name
計算されたフィールドの名前。
- expression
評価して返す式を含む文字列。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 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\u003e\u003ccode\u003eFieldExpression\u003c/code\u003e enables the computation of custom content snippets for each search result.\u003c/p\u003e\n"],["\u003cp\u003eThis API is available for first-generation runtimes and is applicable when upgrading to second-generation runtimes.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFieldExpression\u003c/code\u003e constructor takes a \u003ccode\u003ename\u003c/code\u003e for the computed field and an \u003ccode\u003eexpression\u003c/code\u003e to define how the content is generated.\u003c/p\u003e\n"],["\u003cp\u003eThe properties \u003ccode\u003ename\u003c/code\u003e and \u003ccode\u003eexpression\u003c/code\u003e hold the name of the computed field and the string defining its expression, respectively.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFieldExpression\u003c/code\u003e will raise a TypeError or ValueError exception if invalid types or values are passed during instantiation.\u003c/p\u003e\n"]]],[],null,["# The FieldExpression Class\n\nClass `FieldExpression` allows you to compute customized content snippets for each result returned by a search.\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`FieldExpression` is defined in the module `google.appengine.api.search`.\n\nConstructor\n-----------\n\nThe constructor for class `FieldExpression` is defined as follows:\n\n\nclass FieldExpression(name, expression)\n\n:\n\n Construct an instance of class `FieldExpression`.\n\n For example, \n\n ```python\n FieldExpression(name='content_snippet',\n expression='snippet(\"very important\", content)')\n ```\n\n constructs a field expression that returns a computed field named `content-snippet` with each search result, containing HTML snippets of the `content` field that match the query `\"very` `important\"`.\n\n \u003cbr /\u003e\n\n:\n\n Arguments\n\n name\n\n : Name of computed field.\n\n expression\n\n : Expression to evaluate and return.\n\n Result value\n\n : A new instance of class `FieldExpression`.\n\n Exceptions\n\n TypeError\n\n : A parameter has an invalid type, or an unknown attribute was passed.\n\n ValueError\n\n : A parameter has an invalid value.\n\n \u003cbr /\u003e\n\nProperties\n----------\n\nAn instance of class `FieldExpression` has the following properties:\n\nname\n\n: Name of computed field.\n\nexpression\n\n: String containing expression to evaluate and return."]]