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 SortOptions Class
Stay organized with collections
Save and categorize content based on your preferences.
Class SortExpression
represents a multi-dimensional sort of Documents.
The following code shows how to sort documents based on product rating
in descending order and then cheapest product within similarly rated
products, sorting at most 1000 documents:
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
is defined in the google.appengine.api.search
module.
Constructor
The constructor for class SortOptions
is defined as follows:
-
class SortOptions(expressions=None, match_scorer=None, limit=1000)
Sort documents according to the specified options.
Arguments
- expressions
An iterable of SortExpression representing a multi-dimensional sort of Documents.
- match_scorer
A match scorer specification which may be used to score documents or in a SortExpression combined with other features.
- limit
The limit on the number of documents to score. It is advisable to set this limit on large indexes.
Result value
A new instance of class SortOptions
.
Exceptions
- TypeError
If any of the parameters have an invalid type, or an unknown attribute is passed.
- ValueError
If any parameter has an invalid value.
Properties
An instance of class SortOptions
has the following properties:
- expressions
Returns a list of SortExpression specifying a multi-dimensional sort.
- match_scorer
Returns a match scorer used to score documents.
- limit
Returns the limit on the number of documents to score.
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-04 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-04 UTC."],[[["The `SortOptions` class enables multi-dimensional sorting of documents, leveraging `SortExpression` for detailed control."],["`SortOptions` allows specifying sorting criteria using an iterable of `SortExpression`, a match scorer, and a limit on the number of documents to sort."],["The `SortOptions` constructor can be configured with `expressions`, `match_scorer`, and `limit`, throwing `TypeError` or `ValueError` if input is invalid."],["`SortExpression` objects can define the direction of sorting, such as ascending or descending, and a default value for the sort key."],["`SortOptions` properties `expressions`, `match_scorer`, and `limit` allow you to access the configured settings for sorting."]]],[]]