Python 2.7 has reached end of support
and will be deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their deprecation date
. We recommend that
you migrate to the latest supported version of Python
.
The FieldExpression Class
Stay organized with collections
Save and categorize content based on your preferences.
Class FieldExpression
allows you to compute customized content snippets for each result returned by a search.
FieldExpression
is defined in the module google.appengine.api.search
.
Constructor
The constructor for class FieldExpression
is defined as follows:
-
class
FieldExpression
( name
, expression
)
-
Construct an instance of class FieldExpression
.
For example,
FieldExpression
(
name
=
'content_snippet'
,
expression
=
'snippet("very important", content)'
)
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"
.
-
Arguments
- name
-
Name of computed field.
- expression
-
Expression to evaluate and return.
Result value
-
A new instance of class FieldExpression
.
Exceptions
- TypeError
-
A parameter has an invalid type, or an unknown attribute was passed.
- ValueError
-
A parameter has an invalid value.
Properties
An instance of class FieldExpression
has the following properties:
- name
-
Name of computed field.
- expression
-
String containing expression to evaluate and return.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-29 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 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."]]