Package com.google.appengine.api.search
Class SortExpression
- java.lang.Object
-
- com.google.appengine.api.search.SortExpression
-
public final class SortExpression extends 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 Description static classSortExpression.BuilderA builder that constructsSortExpressions.static classSortExpression.SortDirectionThe direction search results are sorted by, either ascending or descending.
-
Field Summary
Fields Modifier and Type Field Description static StringDOCUMENT_ID_FIELD_NAMEThe expression to be used if you wish to sort by document id fieldDocument.getId().static StringLANGUAGE_FIELD_NAMEThe expression to be used if you wish to sort by language code associated with the locale fieldDocument.getLocale().static StringRANK_FIELD_NAMEThe expression to be used if you wish to sort by rank field.static StringSCORE_FIELD_NAMEThe expression to be used if you wish to sort by document score.static StringTIMESTAMP_FIELD_NAMEThe expression to be used if you wish to sort by seconds since EPOCH that the document was written.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDefaultValue()DategetDefaultValueDate()DoublegetDefaultValueNumeric()SortExpression.SortDirectiongetDirection()StringgetExpression()static SortExpression.BuildernewBuilder()Creates and returns a SortExpression Builder.StringtoString()
-
-
-
Field Detail
-
DOCUMENT_ID_FIELD_NAME
public static final String DOCUMENT_ID_FIELD_NAME
The expression to be used if you wish to sort by document id fieldDocument.getId(). You need to create a sort expression asSortExpression expr = SortExpression.newBuilder() .setExpression(SortExpression.DOCUMENT_ID_FIELD_NAME) .setDefaultValue("") .build();- See Also:
- Constant Field Values
-
LANGUAGE_FIELD_NAME
public static final String LANGUAGE_FIELD_NAME
The expression to be used if you wish to sort by language code associated with the locale fieldDocument.getLocale(). You need to create a sort expression asSortExpression expr = SortExpression.newBuilder() .setExpression(SortExpression.LANGUAGE_FIELD_NAME) .setDefaultValue("") .build();- See Also:
- Constant Field Values
-
RANK_FIELD_NAME
public static final 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 asSortExpression 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 String SCORE_FIELD_NAME
The expression to be used if you wish to sort by document score. You need to create a sort expression asSortExpression 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
-
TIMESTAMP_FIELD_NAME
public static final String TIMESTAMP_FIELD_NAME
The expression to be used if you wish to sort by seconds since EPOCH that the document was written. You need to create a sort expression asSortExpression expr = SortExpression.newBuilder() .setExpression(SortExpression.TIMESTAMP_FIELD_NAME) .setDefaultValueNumeric(0) .build();- See Also:
- Constant Field Values
-
-
Method Detail
-
getExpression
public 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 String getDefaultValue()
- Returns:
- the default value for the field. Can be null
-
getDefaultValueNumeric
public Double getDefaultValueNumeric()
- Returns:
- the default numeric value for the field. Can be null
-
getDefaultValueDate
public 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 theSortExpression.Builder.build()method to create a concrete instance of SortExpression
-
-