SortExpression.Builder (Google App Engine API for Java)

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 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 expr = SortExpression.newBuilder()
           .setExpression(String.format(
               "%s + count(likes) * 0.1", SortExpression.SCORE_FIELD_NAME))
           .setDirection(SortExpression.SortDirection.ASCENDING)
           .setDefaultValueNumeric(0.0)
           .build()
     
    • Method Detail

      • 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

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

App Engine standard environment for Java