Query (Google App Engine API for Java)


Class Query

  • java.lang.Object
    • com.google.appengine.api.search.Query

  • public class Query
    extends java.lang.Object
    A query to search an index for documents which match, restricting the document fields returned to those given, and scoring and sorting the results, whilst supporting pagination.

    For example, the following query will search for documents where the tokens 'good' and 'story' occur in some fields, returns 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 options = QueryOptions.newBuilder()
         .setFieldsToSnippet("subject", "body")
     Query query = Query.newBuilder()
         .build("good story");
    The following query will return facet information with the query result:
     Query query = Query.newBuilder()
    To customize returned facet or refine the result using a previously returned FacetResultValue.getRefinementToken():
     Query query = Query.newBuilder()

    • Method Detail

      • getQueryString

        public java.lang.String getQueryString()
        The query 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").
        the query
      • getOptions

        public QueryOptions getOptions()
        Returns the QueryOptions for controlling the what is returned in the result set matching the query
      • getFacetOptions

        public FacetOptions getFacetOptions()
        Returns the FacetOptions for controlling faceted search or null if unset.
      • getEnableFacetDiscovery

        public boolean getEnableFacetDiscovery()
        Returns true if facet discovery is enabled.
      • getReturnFacets

        public <any> getReturnFacets()
        Returns an unmodifiable list of requests for facets to be returned with the search results.
      • getRefinements

        public <any> getRefinements()
        Returns an unmodifiable list of facet refinements for the search.
      • newBuilder

        public static Query.Builder newBuilder(Query query)
        Creates a builder from the given query.
        query - the query for the builder to use to build another query
        a new builder with values based on the given request
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object