Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



The SortExpression Class

Class SortExpression allows you to customize how your search results are sorted.

SortExpression is defined in the google.appengine.api.search module.

  1. Constructor
  2. Properties:

Constructor

The constructor for class SortExpression is defined as follows:

class SortExpression ( expression = None , direction = DESCENDING , default_value = None )

Sort results by the specified scoring expression.

Arguments

expression

An expression to be evaluated when sorting results for each matching document. The expression can simply be a field name, or some compound expression such as _score + count(likes) * 0.1 which will add the score from a scorer to a count of the values of a likes field weighted by a factor of 0.1.

direction

The direction to sort the search results, either ASCENDING or DESCENDING.

default_value

The default value of the expression, if no field is present and cannot be calculated for a document. A text value must be specified for text sorts. A numeric value must be specified for numeric sorts.

Result value

A new instance of class SortExpression .

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 SortExpression has the following properties:

expression

Returns the expression used to sort matched results.

direction

Returns the direction of sort expression: ASCENDING or DESCENDING .

default_value

Returns a default value for the expression if no other value could be computed.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.