Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.api.search
Class SortExpression.Builder

    java.lang.Object
      com.google.appengine.api.search.SortExpression.Builder

Enclosing class:
  SortExpression

    public static final class SortExpression.Builder

extends java.lang.Object

A builder that constructs `SortExpressions`. The user must provide an expression. The expression can be as simple as a field name, or can be some other evaluable expression such as 'score + count(likes) * 0.1' which combines a scorer score with a count of the number of likes values times 0.1. A default value must be specified for the expression.

       SortExpression spec = SortExpression.newBuilder()
           .setExpression("score + count(likes) * 0.1")
           .setDirection(Scorer.SortDirection.DESCENDING)
           .setDefaultValueNumeric(0.0)
           .build()

Method Summary
`SortExpression` | `build()` Builds a `SortExpression` from the set values.
`SortExpression.Builder` | `setDefaultValue(java.lang.String defaultValue)` Sets the default value for the field for sorting purposes.
`SortExpression.Builder` | `setDefaultValueNumeric(double defaultValue)` Sets the default value for the field for sorting purposes.
`SortExpression.Builder` | `setDirection(com.google.appengine.api.search.SortExpression.SortDirection direction)` Sets the direction to sort the search results in.
`SortExpression.Builder` | `setExpression(java.lang.String expression)` Sets an expression to be evaluated for each document to sort by.
`SortExpression.Builder` | `setLimit(int limit)` Sets the limit on the number of documents to sort.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### setLimit

    public SortExpression.Builder setLimit(int limit)

  Sets the limit on the number of documents to sort.

  Parameters:
    `limit` - the maximum number of documents to sort
  Returns:
    this builder
  Throws:
    `java.lang.IllegalArgumentException` - if the limit is out of range

### setExpression

    public SortExpression.Builder setExpression(java.lang.String expression)

  Sets an expression to be evaluated for each document to sort by. A default string value `#setDefaultValue()` or numeric `setDefaultValueNumeric(double)` must be specified for the expression.

  Parameters:
    `expression` - the expression to evaluate for each document to sort by
  Returns:
    this Builder
  Throws:
    `java.lang.IllegalArgumentException` - if the expression is invalid

### setDirection

    public SortExpression.Builder setDirection(com.google.appengine.api.search.SortExpression.SortDirection direction)

  Sets the direction to sort the search results in.

  Parameters:
    `direction` - the direction to sort the search results in. The default direction is `SortDirection#DESCENDING`
  Returns:
    this Builder

### setDefaultValue

    public SortExpression.Builder setDefaultValue(java.lang.String defaultValue)

  Sets the default value for the field for sorting purposes. Must provide for text sorts.

  Parameters:
    `defaultValue` - the default value for the field
  Returns:
    this Builder
  Throws:
    `java.lang.IllegalArgumentException` - if the `defaultValue` is not valid

### setDefaultValueNumeric

    public SortExpression.Builder setDefaultValueNumeric(double defaultValue)

  Sets the default value for the field for sorting purposes. Must provide for numeric sorts.

  Parameters:
    `defaultValue` - the default value for the field
  Returns:
    this Builder

### build

    public SortExpression build()

  Builds a `SortExpression` from the set values.

  Returns:
    a `SortExpression` built from the set values
  Throws:
    `java.lang.IllegalArgumentException` - if the field name or default value is invalid

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD