Class Query.Builder (2.0.0)

public static class Query.Builder

A builder which constructs Query objects.

Inheritance

java.lang.Object > Query.Builder

Constructors

Builder()

protected Builder()

Methods

addFacetRefinement(FacetRefinement refinement)

public Query.Builder addFacetRefinement(FacetRefinement refinement)

Adds a facet refinement. There will be disjunction between refinements for the same facet and conjunction between refinements for different facets. For example if the refinements are (name=wine_type,value=red), (name=wine_type,value=white) and (name=year, Range(2000,2010)), the result will be refined according to:

((wine_type is red) OR (wine_type is white)) AND (year in Range.closedOpen(2000,2010))

Parameter
Name Description
refinement FacetRefinement

a FacetRefinement object.

Returns
Type Description
Query.Builder

this builder

addFacetRefinementFromToken(String token)

public Query.Builder addFacetRefinementFromToken(String token)

Adds a facet refinement token. The token is returned by each FacetResultValue. There will be disjunction between tokens for the same facet and conjunction between tokens for different facets. For example if the refinement tokens are (name=wine_type,value=red), (name=wine_type,value=white) and (name=year, Range(2000,2010)), the result will be refined according to:

((wine_type is red) OR (wine_type is white)) AND (year in Range(2000,2010))

Parameter
Name Description
token String

the token returned by FacetResultValue#getRefinementToken or FacetRefinement#toTokenString.

Returns
Type Description
Query.Builder

this builder

addReturnFacet(FacetRequest facet)

public Query.Builder addReturnFacet(FacetRequest facet)

Requests a facet to be returned with search results. The facet will be included in the result regardless of the number of values it has.

Parameter
Name Description
facet FacetRequest

the FacetRequest to be added to return facets.

Returns
Type Description
Query.Builder

this builder

addReturnFacet(FacetRequest.Builder builder)

public Query.Builder addReturnFacet(FacetRequest.Builder builder)

Adds a facet request from a builder.

Parameter
Name Description
builder FacetRequest.Builder

the FacetRequest.Builder build a FacetRequest to be added to return facets.

Returns
Type Description
Query.Builder

this builder

addReturnFacet(String facetName)

public Query.Builder addReturnFacet(String facetName)

Adds a facet request by its name only.

Parameter
Name Description
facetName String

the name of the facet to be added to return facets.

Returns
Type Description
Query.Builder

this builder

build()

public Query build()

Construct the message.

Returns
Type Description
Query

the Query built from the parameters entered on this Builder

build(String queryString)

public Query build(String queryString)

Build a Query from the query string and the parameters set on the Builder. A query string can be as simple as a single term ("foo"), or as complex as a boolean expression, including field names ("title:hello OR body:important -october").

Parameter
Name Description
queryString String

the query string to parse and apply to an index

Returns
Type Description
Query

the Query built from the parameters entered on this Builder including the queryString

setEnableFacetDiscovery(boolean value)

public Query.Builder setEnableFacetDiscovery(boolean value)

Sets enable facet discovery flag.

Parameter
Name Description
value boolean
Returns
Type Description
Query.Builder

this builder

setFacetOptions(FacetOptions options)

public Query.Builder setFacetOptions(FacetOptions options)

Sets the facet options.

Parameter
Name Description
options FacetOptions

the FacetOptions to apply to the facet results

Returns
Type Description
Query.Builder

this builder

setFacetOptions(FacetOptions.Builder builder)

public Query.Builder setFacetOptions(FacetOptions.Builder builder)

Sets the facet options from a builder.

Parameter
Name Description
builder FacetOptions.Builder

the FacetOptions.Builder build a FacetOptions to apply to the facet results

Returns
Type Description
Query.Builder

this builder

setOptions(QueryOptions options)

public Query.Builder setOptions(QueryOptions options)

Sets the query options.

Parameter
Name Description
options QueryOptions

the QueryOptions to apply to the search results

Returns
Type Description
Query.Builder

this builder

setOptions(QueryOptions.Builder optionsBuilder)

public Query.Builder setOptions(QueryOptions.Builder optionsBuilder)

Sets the query options from a builder.

Parameter
Name Description
optionsBuilder QueryOptions.Builder

the QueryOptions.Builder build a QueryOptions to apply to the search results

Returns
Type Description
Query.Builder

this builder

setQueryString(String query)

protected Query.Builder setQueryString(String query)

Sets the query string used to construct the query.

Parameter
Name Description
query String

a query string used to construct the query

Returns
Type Description
Query.Builder

this Builder