com.google.appengine.api.search

## Class Query.Builder

- java.lang.Object
- - com.google.appengine.api.search.Query.Builder

- Enclosing class:
    Query

      public static class Query.Builder
      extends java.lang.Object

  A builder which constructs Query objects.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Query.Builder` | `addFacetRefinement(FacetRefinement refinement)` Adds a facet refinement.
    `Query.Builder` | `addFacetRefinementFromToken(java.lang.String token)` Adds a facet refinement token.
    `Query.Builder` | `addReturnFacet(FacetRequest.Builder builder)` Adds a facet request from a builder.
    `Query.Builder` | `addReturnFacet(FacetRequest facet)` Requests a facet to be returned with search results.
    `Query.Builder` | `addReturnFacet(java.lang.String facetName)` Adds a facet request by its name only.
    `Query` | `build()` Construct the message.
    `Query` | `build(java.lang.String queryString)` Build a `Query` from the query string and the parameters set on the `Query.Builder`.
    `Query.Builder` | `setEnableFacetDiscovery(boolean value)` Sets enable facet discovery flag.
    `Query.Builder` | `setFacetOptions(FacetOptions.Builder builder)` Sets the facet options from a builder.
    `Query.Builder` | `setFacetOptions(FacetOptions options)` Sets the facet options.
    `Query.Builder` | `setOptions(QueryOptions.Builder optionsBuilder)` Sets the query options from a builder.
    `Query.Builder` | `setOptions(QueryOptions options)` Sets the query options.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### setOptions

          public Query.Builder setOptions(QueryOptions options)

      Sets the query options.
      Parameters:
        `options` - the `QueryOptions` to apply to the search results
      Returns:
        this builder

    - #### setOptions

          public Query.Builder setOptions(QueryOptions.Builder optionsBuilder)

      Sets the query options from a builder.
      Parameters:
        `optionsBuilder` - the `QueryOptions.Builder` build a `QueryOptions` to apply to the search results
      Returns:
        this builder

    - #### setFacetOptions

          public Query.Builder setFacetOptions(FacetOptions options)

      Sets the facet options.
      Parameters:
        `options` - the `FacetOptions` to apply to the facet results
      Returns:
        this builder

    - #### setFacetOptions

          public Query.Builder setFacetOptions(FacetOptions.Builder builder)

      Sets the facet options from a builder.
      Parameters:
        `builder` - the `FacetOptions.Builder` build a `FacetOptions` to apply to the facet results
      Returns:
        this builder

    - #### setEnableFacetDiscovery

          public Query.Builder setEnableFacetDiscovery(boolean value)

      Sets enable facet discovery flag.
      Returns:
        this builder

    - #### addReturnFacet

          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.
      Parameters:
        `facet` - the `FacetRequest` to be added to return facets.
      Returns:
        this builder

    - #### addFacetRefinementFromToken

          public Query.Builder addFacetRefinementFromToken(java.lang.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))

      Parameters:
        `token` - the token returned by `FacetResultValue.getRefinementToken()` or `FacetRefinement.toTokenString()`.
      Returns:
        this builder
      Throws:
        `java.lang.IllegalArgumentException` - if token is not valid.

    - #### addFacetRefinement

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

      Parameters:
        `refinement` - a `FacetRefinement` object.
      Returns:
        this builder

    - #### addReturnFacet

          public Query.Builder addReturnFacet(FacetRequest.Builder builder)

      Adds a facet request from a builder.
      Parameters:
        `builder` - the `FacetRequest.Builder` build a `FacetRequest` to be added to return facets.
      Returns:
        this builder

    - #### addReturnFacet

          public Query.Builder addReturnFacet(java.lang.String facetName)

      Adds a facet request by its name only.
      Parameters:
        `facetName` - the name of the facet to be added to return facets.
      Returns:
        this builder

    - #### build

          public Query build(java.lang.String queryString)

      Build a `Query` from the query string and the parameters set on the `Query.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").
      Parameters:
        `queryString` - the query string to parse and apply to an index
      Returns:
        the Query built from the parameters entered on this Builder including the queryString
      Throws:
        `SearchQueryException` - if the query string is invalid

    - #### build

          public Query build()

      Construct the message.
      Returns:
        the Query built from the parameters entered on this Builder
      Throws:
        `java.lang.IllegalArgumentException` - if the query string is invalid