Class QueryOptions (2.0.0)

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();
 

Inheritance

java.lang.Object > QueryOptions

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
TypeDescription
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
NameDescription
requestQueryOptions

the search request for the builder to use to build another request

Returns
TypeDescription
QueryOptions.Builder

a new builder with values set from the given request

Methods

getCursor()

public Cursor getCursor()
Returns
TypeDescription
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
TypeDescription
List<FieldExpression>

an unmodifiable list of expressions which will be evaluated and returned in results

getFieldsToReturn()

public List<String> getFieldsToReturn()
Returns
TypeDescription
List<String>

an unmodifiable list of names of fields to return in search results

getFieldsToSnippet()

public List<String> getFieldsToSnippet()
Returns
TypeDescription
List<String>

an unmodifiable list of names of fields to snippet in search results

getLimit()

public int getLimit()
Returns
TypeDescription
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
TypeDescription
int

the found count accuracy

getOffset()

public int getOffset()
Returns
TypeDescription
int

the offset of the first result to return; returns 0 if was not set

getSortOptions()

public SortOptions getSortOptions()
Returns
TypeDescription
SortOptions

a SortOptions specifying how to sort Documents in Results

hasNumberFoundAccuracy()

public boolean hasNumberFoundAccuracy()

Returns true iff there is an accuracy requirement set.

Returns
TypeDescription
boolean

the found count accuracy

isReturningIdsOnly()

public boolean isReturningIdsOnly()
Returns
TypeDescription
boolean

if this search request returns results document IDs only

toString()

public String toString()
Returns
TypeDescription
String
Overrides