Query.Builder (Google App Engine API for Java)

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 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
      • setFacetOptions

        public Query.Builder setFacetOptions(FacetOptions options)
        Sets the facet options.
        Parameters:
        options - the 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(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

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

App Engine standard environment for Java