Class QueryOptions
- java.lang.Object
-
- com.google.appengine.api.search.QueryOptions
-
public final class QueryOptions extends java.lang.Object
Represents options which control where and what in the search results to return, from restricting the document fields returned to those given, and scoring and sorting the results, whilst supporting pagination.For example, the following options will return documents from search results for some given query, returning up to 20 results including the fields 'author' and 'date-sent' as well as snippeted fields 'subject' and 'body'. The results are sorted by 'author' in descending order, getting the next 20 results from the responseCursor in the previously returned results, giving back a single cursor in the
Results
to get the next batch of results after this.QueryOptions request = QueryOptions.newBuilder() .setLimit(20) .setFieldsToReturn("author", "date-sent") .setFieldsToSnippet("subject", "body") .setSortOptions(SortOptions.newBuilder(). .addSortExpression(SortExpression.newBuilder() .setExpression("author") .setDirection(Scorer.SortDirection.DESCENDING) .setDefaultValue(""))) .setCursor(Cursor.newBuilder().build()) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
QueryOptions.Builder
A builder which constructs QueryOptions objects.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Cursor
getCursor()
java.util.List<FieldExpression>
getExpressionsToReturn()
java.util.List<java.lang.String>
getFieldsToReturn()
java.util.List<java.lang.String>
getFieldsToSnippet()
int
getLimit()
int
getNumberFoundAccuracy()
AnyResults.getNumberFound()
less than or equal to this setting will be accurate.int
getOffset()
SortOptions
getSortOptions()
boolean
hasNumberFoundAccuracy()
Returns true iff there is an accuracy requirement set.boolean
isReturningIdsOnly()
static QueryOptions.Builder
newBuilder()
Creates and returns aQueryOptions
builder.static QueryOptions.Builder
newBuilder(QueryOptions request)
Creates a builder from the given request.java.lang.String
toString()
-
-
-
Method Detail
-
getLimit
public int getLimit()
- Returns:
- the limit on the number of documents to return in search results
-
getCursor
public Cursor getCursor()
- Returns:
- a cursor returned from a previous set of search results to use as a starting point to retrieve the next set of results. Can be null
-
getOffset
public int getOffset()
- Returns:
- the offset of the first result to return; returns 0 if was not set
-
hasNumberFoundAccuracy
public boolean hasNumberFoundAccuracy()
Returns true iff there is an accuracy requirement set.- Returns:
- the found count accuracy
-
getNumberFoundAccuracy
public int getNumberFoundAccuracy()
AnyResults.getNumberFound()
less than or equal to this setting will be accurate.- Returns:
- the found count accuracy
-
getSortOptions
public SortOptions getSortOptions()
- Returns:
- a
SortOptions
specifying how to sort Documents inResults
-
isReturningIdsOnly
public boolean isReturningIdsOnly()
- Returns:
- if this search request returns results document IDs only
-
getFieldsToReturn
public java.util.List<java.lang.String> getFieldsToReturn()
- Returns:
- an unmodifiable list of names of fields to return in search results
-
getFieldsToSnippet
public java.util.List<java.lang.String> getFieldsToSnippet()
- Returns:
- an unmodifiable list of names of fields to snippet in search results
-
getExpressionsToReturn
public java.util.List<FieldExpression> getExpressionsToReturn()
- Returns:
- an unmodifiable list of expressions which will be evaluated and returned in results
-
newBuilder
public static QueryOptions.Builder newBuilder()
Creates and returns aQueryOptions
builder. Set the search request parameters and use theQueryOptions.Builder.build()
method to create a concrete instance of QueryOptions.- Returns:
- a
QueryOptions.Builder
which can construct a search request
-
newBuilder
public static QueryOptions.Builder newBuilder(QueryOptions request)
Creates a builder from the given request.- Parameters:
request
- the search request for the builder to use to build another request- Returns:
- a new builder with values set from the given request
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-