La classe FieldExpression
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
La classe FieldExpression
vous permet de calculer des extraits de contenu personnalisés pour chaque résultat affiché par une recherche.
La classe FieldExpression
est définie dans le module google.appengine.api.search
.
Constructeur
Le constructeur de la classe FieldExpression
est défini comme suit :
-
class FieldExpression(name, expression)
Construire une instance de la classe FieldExpression
.
Exemple :
FieldExpression(name='content_snippet',
expression='snippet("very important", content)')
Construit une expression de champ qui affiche un champ calculé nommé content-snippet
avec chaque résultat de recherche, contenant des extraits HTML du champ content
correspondant à la requête "very
important"
.
Arguments
- name
Nom du champ calculé.
- expression
Expression à évaluer et à afficher.
Result value
Nouvelle instance de la classe FieldExpression
.
Exceptions
- TypeError
L'un des paramètres possède un type non valide ou un attribut inconnu a été transmis.
- ValueError
L'un des paramètres contient une valeur non valide.
Propriétés
Une instance de la classe FieldExpression
possède les propriétés suivantes :
- name
Nom du champ calculé.
- expression
Chaîne contenant une expression à évaluer et à afficher.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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."]]