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 FacetRefinement Class
Stay organized with collections
Save and categorize content based on your preferences.
Class FacetRefinement
is used to narrow search results based on a facet value.
The recommended way to use facet refinement is to use its token string. Each FacetResult will
have a token that is acceptable instead of this class. To provide manual FacetRefinement, an
instance of this class can be passed to SearchOptions.
FacetRefinement
is defined in the module google.appengine.api.search
.
Constructor
The constructor for class FacetRefinement
is defined as follows:
class FacetRefinement(name, value=None, facet_range=None)
Construct an instance of class FacetRefinement
.
NOTE: Either the value or the facet_range should be set but not both.
Arguments
- name
Sets the name property
- value
Sets the value property
- facet_range
Sets the facet_range property
Result value
A new instance of class FacetRefinement
.
Exceptions
- TypeError
If any of the parameters have invalid types, or an unknown
attribute is passed.
- ValueError
If any of the parameters have invalid values.
Properties
An instance of class FacetRefinement
has the following properties:
- name
name of the facet refinement.
- value
string value of the facet refinement.
- range
numeric range of the facet refinement.
Instance Methods
Instances of class FacetRefinement
have the following methods:
- ToTokenString()
Converts this refinement to a token string safe to be used in HTML. The format of this string may change.
-
Result value
A token string safe to be used in HTML for this facet refinement.
- FromTokenString()
This static method converts a token string to a FacetRefinement object. Do not store token strings between different versions of API as key could
be incompatible.
-
Arguments
- token_string
A token string created by ToTokenString method or returned
by a search result.
Result value
A FacetRefinement object.
Exceptions
- ValueError
If the token_string is invalid.
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-07 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-07 UTC."],[[["The `FacetRefinement` class is used to refine search results based on a specific facet value."],["While manual `FacetRefinement` is possible, using the token string from `FacetResult` is the recommended approach."],["The `FacetRefinement` constructor accepts a name, a value, or a `facet_range`, but only one of the value or facet_range can be specified."],["`FacetRefinement` instances have `name`, `value`, and `range` properties that define the refinement."],["`FacetRefinement` objects can be converted to token strings using `ToTokenString()` and can be created from a token string using the `FromTokenString()` method."]]],[]]