|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.appengine.api.search.SortSpec.Builder
public static final class SortSpec.Builder
A builder that constructs SortSpecs. There are
two kinds of SortSpec: custom or scorer. In a custom SortSpec, 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.
SortSpec spec = SortSpec.newBuilder()
.setType(ScorerType.CUSTOM)
.setExpression("score + count(likes) * 0.1")
.setDirection(SortSpec.SortDirection.DESCENDING)
.build()
A scoring SortSpec will invoke a scorer on each search result. The
following code illustrates setting a match scorer to score documents,
scoring at most 1000 documents.
SortSpec spec = SortSpec.newBuilder()
.setType(SortType.MATCH_SCORER)
.setLimit(1000)
.build()
| Method Summary | |
|---|---|
SortSpec |
build()
Builds a SortSpec from the set values. |
SortSpec.Builder |
setDefaultValue(java.lang.String defaultValue)
Sets the default value for the field for sorting purposes. |
SortSpec.Builder |
setDefaultValueNumeric(double defaultValue)
Sets the default value for the field for sorting purposes. |
SortSpec.Builder |
setDirection(SortSpec.SortDirection direction)
Sets the direction to sort the search results in. |
SortSpec.Builder |
setExpression(java.lang.String expression)
Sets an expression to be evaluated for each document to sort by. |
SortSpec.Builder |
setLimit(int limit)
Sets the limit on the number of documents to score. |
SortSpec.Builder |
setType(SortSpec.SortType type)
Sets the type of SortSpec to build. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public SortSpec.Builder setType(SortSpec.SortType type)
type - the type of SortSpec to build
public SortSpec.Builder setLimit(int limit)
limit - the maximum number of documents to score
public SortSpec.Builder setExpression(java.lang.String expression)
expression - the expression to evaluate for each
document to sort by
java.lang.IllegalArgumentException - if the expression is invalidpublic SortSpec.Builder setDirection(SortSpec.SortDirection direction)
direction - the direction to sort the search results in. The
default direction is SortSpec.SortDirection.DESCENDING
public SortSpec.Builder setDefaultValue(java.lang.String defaultValue)
defaultValue - the default value for the field
java.lang.IllegalArgumentException - if the defaultValue is not validpublic SortSpec.Builder setDefaultValueNumeric(double defaultValue)
defaultValue - the default value for the field
public SortSpec build()
SortSpec from the set values.
SortSpec built from the set values
java.lang.IllegalArgumentException - if the field name or
default value is invalid
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||