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.