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
NameDescription
refinementFacetRefinement

a FacetRefinement object.

Returns
TypeDescription
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
NameDescription
tokenString

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

Returns
TypeDescription
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
NameDescription
facetFacetRequest

the FacetRequest to be added to return facets.

Returns
TypeDescription
Query.Builder

this builder

addReturnFacet(FacetRequest.Builder builder)

public Query.Builder addReturnFacet(FacetRequest.Builder builder)

Adds a facet request from a builder.

Parameter
NameDescription
builderFacetRequest.Builder

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

Returns
TypeDescription
Query.Builder

this builder

addReturnFacet(String facetName)

public Query.Builder addReturnFacet(String facetName)

Adds a facet request by its name only.

Parameter
NameDescription
facetNameString

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

Returns
TypeDescription
Query.Builder

this builder

build()

public Query build()

Construct the message.

Returns
TypeDescription
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
NameDescription
queryStringString

the query string to parse and apply to an index

Returns
TypeDescription
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
NameDescription
valueboolean
Returns
TypeDescription
Query.Builder

this builder

setFacetOptions(FacetOptions options)

public Query.Builder setFacetOptions(FacetOptions options)

Sets the facet options.

Parameter
NameDescription
optionsFacetOptions

the FacetOptions to apply to the facet results

Returns
TypeDescription
Query.Builder

this builder

setFacetOptions(FacetOptions.Builder builder)

public Query.Builder setFacetOptions(FacetOptions.Builder builder)

Sets the facet options from a builder.

Parameter
NameDescription
builderFacetOptions.Builder

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

Returns
TypeDescription
Query.Builder

this builder

setOptions(QueryOptions options)

public Query.Builder setOptions(QueryOptions options)

Sets the query options.

Parameter
NameDescription
optionsQueryOptions

the QueryOptions to apply to the search results

Returns
TypeDescription
Query.Builder

this builder

setOptions(QueryOptions.Builder optionsBuilder)

public Query.Builder setOptions(QueryOptions.Builder optionsBuilder)

Sets the query options from a builder.

Parameter
NameDescription
optionsBuilderQueryOptions.Builder

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

Returns
TypeDescription
Query.Builder

this builder

setQueryString(String query)

protected Query.Builder setQueryString(String query)

Sets the query string used to construct the query.

Parameter
NameDescription
queryString

a query string used to construct the query

Returns
TypeDescription
Query.Builder

this Builder