com.google.appengine.api.search
Class QueryOptions.Builder
- java.lang.Object
- 
- com.google.appengine.api.search.QueryOptions.Builder
 
- 
- Enclosing class:
- QueryOptions
 
 
 public static final class QueryOptions.Builder extends java.lang.ObjectA builder which constructs QueryOptions objects.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method and Description QueryOptions.BuilderaddExpressionToReturn(FieldExpression.Builder expressionBuilder)Adds aFieldExpressionbuild from the givenexpressionBuilderto return in search results.QueryOptions.BuilderaddExpressionToReturn(FieldExpression expression)Adds aFieldExpressionto return in search results.QueryOptionsbuild()Construct the final message.QueryOptions.BuilderclearNumberFoundAccuracy()Clears any accuracy requirement forResults.getNumberFound().QueryOptions.BuildersetCursor(Cursor.Builder cursorBuilder)Sets a cursor built from the builder.QueryOptions.BuildersetCursor(Cursor cursor)Sets the cursor.QueryOptions.BuildersetFieldsToReturn(java.lang.String... fields)Specifies one or more fields to return in results.QueryOptions.BuildersetFieldsToSnippet(java.lang.String... fieldsToSnippet)Specifies one or more fields to snippet in results.QueryOptions.BuildersetLimit(int limit)Sets the limit on the number of documents to return inResults.QueryOptions.BuildersetNumberFoundAccuracy(int numberFoundAccuracy)Sets the accuracy requirement forResults.getNumberFound().QueryOptions.BuildersetOffset(int offset)Sets the offset of the first result to return.QueryOptions.BuildersetReturningIdsOnly(boolean idsOnly)Sets whether or not the search should return documents or document IDs only.QueryOptions.BuildersetSortOptions(SortOptions.Builder builder)Sets aSortOptionsusing a builder.QueryOptions.BuildersetSortOptions(SortOptions sortOptions)Sets aSortOptionsto sort documents with.
 
- 
- 
- 
Method Detail- 
setLimitpublic QueryOptions.Builder setLimit(int limit) Sets the limit on the number of documents to return inResults.- Parameters:
- limit- the number of documents to return
- Returns:
- this Builder
- Throws:
- java.lang.IllegalArgumentException- if numDocumentsToReturn is not within acceptable range
 
 - 
setCursorpublic QueryOptions.Builder setCursor(Cursor cursor) Sets the cursor. The cursor is obtained from either aResultsor one of the individualScoredDocuments. 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 singleCursoris 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();- Parameters:
- 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
- Returns:
- this Builder
 
 - 
setCursorpublic QueryOptions.Builder setCursor(Cursor.Builder cursorBuilder) Sets a cursor built from the builder.- Parameters:
- cursorBuilder- a- Cursor.Builderthat is used to build a- Cursor.
- Returns:
- this Builder
- See Also:
- setCursor(Cursor)
 
 - 
setOffsetpublic QueryOptions.Builder setOffset(int offset) Sets the offset of the first result to return.- Parameters:
- offset- the offset into all search results to return the limit amount of results
- Returns:
- this Builder
- Throws:
- java.lang.IllegalArgumentException- if the offset is negative or is larger than- SearchApiLimits.SEARCH_MAXIMUM_OFFSET
 
 - 
setNumberFoundAccuracypublic QueryOptions.Builder setNumberFoundAccuracy(int numberFoundAccuracy) Sets the accuracy requirement forResults.getNumberFound(). If set,getNumberFound()will be accurate up to at least that number. For example, when set to 100, anygetNumberFound() <= 100is accurate. This option may add considerable latency / expense, especially when used withsetFieldsToReturn(String...).- Parameters:
- numberFoundAccuracy- the minimum accuracy requirement
- Returns:
- this Builder
- Throws:
- java.lang.IllegalArgumentException- if the accuracy is not within acceptable range
 
 - 
clearNumberFoundAccuracypublic QueryOptions.Builder clearNumberFoundAccuracy() Clears any accuracy requirement forResults.getNumberFound().
 - 
setFieldsToReturnpublic QueryOptions.Builder setFieldsToReturn(java.lang.String... fields) Specifies one or more fields to return in results.- Parameters:
- fields- the names of fields to return in results
- Returns:
- this Builder
- Throws:
- java.lang.IllegalArgumentException- if any of the field names is invalid
 
 - 
setFieldsToSnippetpublic QueryOptions.Builder setFieldsToSnippet(java.lang.String... fieldsToSnippet) Specifies one or more fields to snippet in results. Snippets will be returned as fields with the same names inScoredDocument.getExpressions().- Parameters:
- fieldsToSnippet- the names of fields to snippet in results
- Returns:
- this Builder
- Throws:
- java.lang.IllegalArgumentException- if any of the field names is invalid
 
 - 
addExpressionToReturnpublic QueryOptions.Builder addExpressionToReturn(FieldExpression.Builder expressionBuilder) Adds aFieldExpressionbuild from the givenexpressionBuilderto return in search results. Snippets will be returned as fields with the same names inScoredDocument.getExpressions().- Parameters:
- expressionBuilder- a builder of named expressions to evaluate and return in results
- Returns:
- this Builder
 
 - 
setReturningIdsOnlypublic QueryOptions.Builder setReturningIdsOnly(boolean idsOnly) Sets whether or not the search should return documents or document IDs only. This setting is incompatible withaddExpressionToReturn(FieldExpression)and withsetFieldsToReturn(String...)methods.- Parameters:
- idsOnly- whether or not only IDs of documents are returned by search request
- Returns:
- this Builder
 
 - 
addExpressionToReturnpublic QueryOptions.Builder addExpressionToReturn(FieldExpression expression) Adds aFieldExpressionto return in search results.- Parameters:
- expression- a named expression to compute and return in results
- Returns:
- this Builder
 
 - 
setSortOptionspublic QueryOptions.Builder setSortOptions(SortOptions sortOptions) Sets aSortOptionsto sort documents with.- Parameters:
- sortOptions- specifies how to sort the documents in- Results
- Returns:
- this Builder
 
 - 
setSortOptionspublic QueryOptions.Builder setSortOptions(SortOptions.Builder builder) Sets aSortOptionsusing a builder.- Parameters:
- builder- a builder of a- SortOptions
- Returns:
- this Builder
 
 - 
buildpublic QueryOptions build() Construct the final message.- Returns:
- the QueryOptions built from the parameters entered on this Builder
- Throws:
- java.lang.IllegalArgumentException- if the search request is invalid
 
 
- 
 
-