com.google.appengine.api.search

## Class SortExpression

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

-     public final class SortExpression
      extends java.lang.Object

  Sorting specification for a single dimension. Multi-dimensional sorting is supported by a collection of SortExpressions.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SortExpression.Builder` A builder that constructs `SortExpressions`.
    `static class` | `SortExpression.SortDirection` The direction search results are sorted by, either ascending or descending.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ORDER_ID_FIELD_NAME` Deprecated. Use `RANK_FIELD_NAME` instead.
    `static java.lang.String` | `RANK_FIELD_NAME` The expression to be used if you wish to sort by rank field.
    `static java.lang.String` | `SCORE_FIELD_NAME` The expression to be used if you wish to sort by document score.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getDefaultValue()`
    `java.util.Date` | `getDefaultValueDate()`
    `java.lang.Double` | `getDefaultValueNumeric()`
    `SortExpression.SortDirection` | `getDirection()`
    `java.lang.String` | `getExpression()`
    `static SortExpression.Builder` | `newBuilder()` Creates and returns a SortExpression Builder.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ORDER_ID_FIELD_NAME

          @Deprecated
          public static final java.lang.String ORDER_ID_FIELD_NAME

      Deprecated. Use `RANK_FIELD_NAME` instead.
      See Also:
        Constant Field Values

    - #### RANK_FIELD_NAME

          public static final java.lang.String RANK_FIELD_NAME

      The expression to be used if you wish to sort by rank field. By default, results are sorted in descending value of rank. To sort in ascending order, you need to create a sort expression as

           SortExpression expr = SortExpression.newBuilder()
               .setExpression(SortExpression.RANK_FIELD_NAME)
               .setDirection(SortExpression.SortDirection.ASCENDING)
               .setDefaultValueNumeric(0)
               .build();

      See Also:
        Constant Field Values

    - #### SCORE_FIELD_NAME

          public static final java.lang.String SCORE_FIELD_NAME

      The expression to be used if you wish to sort by document score. You need to create a sort expression as

           SortExpression expr = SortExpression.newBuilder()
               .setExpression(String.format(
                   "%s + rating * 0.01", SortExpression.SCORE_FIELD_NAME))
               .setDirection(SortExpression.SortDirection.DESCENDING)
               .setDefaultValueNumeric(0)
               .build();

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getExpression

          public java.lang.String getExpression()

      Returns:
        the expression to evaluate for each document and sort by

    - #### getDirection

          public SortExpression.SortDirection getDirection()

      Returns:
        the direction to sort the search results in

    - #### getDefaultValue

          public java.lang.String getDefaultValue()

      Returns:
        the default value for the field. Can be null

    - #### getDefaultValueNumeric

          public java.lang.Double getDefaultValueNumeric()

      Returns:
        the default numeric value for the field. Can be null

    - #### getDefaultValueDate

          public java.util.Date getDefaultValueDate()

      Returns:
        the default date value for the field. Can be null

    - #### newBuilder

          public static SortExpression.Builder newBuilder()

      Creates and returns a SortExpression Builder.
      Returns:
        a new `SortExpression.Builder`. Set the parameters for the sort specification on the Builder, and use the `SortExpression.Builder.build()` method to create a concrete instance of SortExpression

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`