public final class QueryOptions
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(SortExpression.SortDirection.DESCENDING)
.setDefaultValue("")))
.setCursor(Cursor.newBuilder().build())
.build();
Static Methods
newBuilder()
public static QueryOptions.Builder newBuilder()
Creates and returns a QueryOptions builder. Set the search request parameters and use the Builder#build() method to create a concrete instance of QueryOptions.
Returns | |
---|---|
Type | Description |
QueryOptions.Builder |
a Builder which can construct a search request |
newBuilder(QueryOptions request)
public static QueryOptions.Builder newBuilder(QueryOptions request)
Creates a builder from the given request.
Parameter | |
---|---|
Name | Description |
request |
QueryOptions the search request for the builder to use to build another request |
Returns | |
---|---|
Type | Description |
QueryOptions.Builder |
a new builder with values set from the given request |
Methods
getCursor()
public Cursor getCursor()
Returns | |
---|---|
Type | Description |
Cursor |
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 |
getExpressionsToReturn()
public List<FieldExpression> getExpressionsToReturn()
Returns | |
---|---|
Type | Description |
List<FieldExpression> |
an unmodifiable list of expressions which will be evaluated and returned in results |
getFieldsToReturn()
public List<String> getFieldsToReturn()
Returns | |
---|---|
Type | Description |
List<String> |
an unmodifiable list of names of fields to return in search results |
getFieldsToSnippet()
public List<String> getFieldsToSnippet()
Returns | |
---|---|
Type | Description |
List<String> |
an unmodifiable list of names of fields to snippet in search results |
getLimit()
public int getLimit()
Returns | |
---|---|
Type | Description |
int |
the limit on the number of documents to return in search results |
getNumberFoundAccuracy()
public int getNumberFoundAccuracy()
Any Results#getNumberFound() less than or equal to this setting will be accurate.
Returns | |
---|---|
Type | Description |
int |
the found count accuracy |
getOffset()
public int getOffset()
Returns | |
---|---|
Type | Description |
int |
the offset of the first result to return; returns 0 if was not set |
getSortOptions()
public SortOptions getSortOptions()
Returns | |
---|---|
Type | Description |
SortOptions |
a SortOptions specifying how to sort Documents in Results |
hasNumberFoundAccuracy()
public boolean hasNumberFoundAccuracy()
Returns true iff there is an accuracy requirement set.
Returns | |
---|---|
Type | Description |
boolean |
the found count accuracy |
isReturningIdsOnly()
public boolean isReturningIdsOnly()
Returns | |
---|---|
Type | Description |
boolean |
if this search request returns results document IDs only |
toString()
public String toString()
Returns | |
---|---|
Type | Description |
String |