|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.appengine.api.search.QueryOptions.Builder
public static final class QueryOptions.Builder
A builder which constructs QueryOptions objects.
Method Summary | |
---|---|
QueryOptions.Builder |
addExpressionToReturn(FieldExpression.Builder expressionBuilder)
Adds a FieldExpression build from the given
expressionBuilder to return in search results. |
QueryOptions.Builder |
addExpressionToReturn(FieldExpression expression)
Adds a FieldExpression to return in search results. |
QueryOptions |
build()
Construct the final message. |
QueryOptions.Builder |
setCursor(Cursor.Builder cursorBuilder)
Sets a cursor built from the builder. |
QueryOptions.Builder |
setCursor(Cursor cursor)
Sets the cursor. |
QueryOptions.Builder |
setFieldsToReturn(java.lang.String... fields)
Specifies one or more fields to return in results. |
QueryOptions.Builder |
setFieldsToSnippet(java.lang.String... fieldsToSnippet)
Specifies one or more fields to snippet in results. |
QueryOptions.Builder |
setLimit(int limit)
Sets the limit on the number of documents to return in Results . |
QueryOptions.Builder |
setNumberFoundAccuracy(int numberFoundAccuracy)
Sets the accuracy requirement for Results.getNumberFound() . |
QueryOptions.Builder |
setOffset(int offset)
Sets the offset of the first result to return. |
QueryOptions.Builder |
setReturningIdsOnly(boolean idsOnly)
Sets whether or not the search should return documents or document IDs only. |
QueryOptions.Builder |
setSortOptions(SortOptions.Builder builder)
Sets a SortOptions using a builder. |
QueryOptions.Builder |
setSortOptions(SortOptions sortOptions)
Sets a SortOptions to sort documents with. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public QueryOptions.Builder setLimit(int limit)
Results
.
limit
- the number of documents to return
java.lang.IllegalArgumentException
- if numDocumentsToReturn is
not within acceptable rangepublic QueryOptions.Builder setCursor(Cursor cursor)
Results
or one of the individual
ScoredDocuments
.
This is illustrated from the following code fragment:
Cursor cursor = Cursor.newBuilder().build(); SearchResults results = index.search( Query.newBuilder() .setOptions(QueryOptions.newBuilder() .setLimit(20) .setCursor(cursor) .build()) .build("some query")); // If the Cursor is built without setPerResult(true), then // by default a singleCursor
is returned with the //Results
. cursor = results.getCursor(); for (ScoredDocument result : results) { // If you set Cursor.newBuilder().setPerResult(true) // then a cursor is returned with each result. result.getCursor();
cursor
- use a cursor returned from a
previous set of search results as a starting point to retrieve
the next set of results. This can get you better performance, and
also improves the consistency of pagination through index updates
public QueryOptions.Builder setCursor(Cursor.Builder cursorBuilder)
cursorBuilder
- a Cursor.Builder
that is used to build
a
Cursor
#setCursor(Cursor)}
public QueryOptions.Builder setOffset(int offset)
offset
- the offset into all search results to return the limit
amount of results
java.lang.IllegalArgumentException
- if the offset is negative or is larger
than QueryOptionsChecker.MAXIMUM_OFFSET
public QueryOptions.Builder setNumberFoundAccuracy(int numberFoundAccuracy)
Results.getNumberFound()
. If set,
getNumberFound()
will be accurate up to at least that number.
For example, when set to 100, any getNumberFound()
<= 100 is
accurate. This option may add considerable latency / expense, especially
when used with setFieldsToReturn(String...)
.
numberFoundAccuracy
- the minimum accuracy requirement
java.lang.IllegalArgumentException
- if the accuracy is not within
acceptable rangepublic QueryOptions.Builder setFieldsToReturn(java.lang.String... fields)
fields
- the names of fields to return in results
java.lang.IllegalArgumentException
- if any of the field names is invalidpublic QueryOptions.Builder setFieldsToSnippet(java.lang.String... fieldsToSnippet)
ScoredDocument.getExpressions()
.
fieldsToSnippet
- the names of fields to snippet in results
java.lang.IllegalArgumentException
- if any of the field names is invalidpublic QueryOptions.Builder addExpressionToReturn(FieldExpression.Builder expressionBuilder)
FieldExpression
build from the given
expressionBuilder
to return in search results. Snippets will be
returned as fields with the same names in
ScoredDocument.getExpressions()
.
expressionBuilder
- a builder of named expressions to
evaluate and return in results
public QueryOptions.Builder setReturningIdsOnly(boolean idsOnly)
addExpressionToReturn(FieldExpression)
and with
setFieldsToReturn(String...)
methods.
idsOnly
- whether or not only IDs of documents are returned by search request
public QueryOptions.Builder addExpressionToReturn(FieldExpression expression)
FieldExpression
to return in search results.
expression
- a named expression to compute and return in results
public QueryOptions.Builder setSortOptions(SortOptions sortOptions)
SortOptions
to sort documents with.
sortOptions
- specifies how to sort the documents in Results
public QueryOptions.Builder setSortOptions(SortOptions.Builder builder)
SortOptions
using a builder.
builder
- a builder of a SortOptions
public QueryOptions build()
java.lang.IllegalArgumentException
- if the search request is invalid
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |