QueryOptions (Google App Engine API for Java)

com.google.appengine.api.search

Class QueryOptions

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


  • public final class QueryOptions
    extends java.lang.Object
    Represents options which control where and what in the search results to return, from restricting the document fields returned to those given, and scoring and sorting the results, whilst supporting pagination.

    For example, the following options will return documents from search results for some given query, returning 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 request = QueryOptions.newBuilder()
          .setLimit(20)
          .setFieldsToReturn("author", "date-sent")
          .setFieldsToSnippet("subject", "body")
          .setSortOptions(SortOptions.newBuilder().
              .addSortExpression(SortExpression.newBuilder()
                  .setExpression("author")
                  .setDirection(Scorer.SortDirection.DESCENDING)
                  .setDefaultValue("")))
    
          .setCursor(Cursor.newBuilder().build())
          .build();
     
    • Method Detail

      • getLimit

        public int getLimit()
        Returns:
        the limit on the number of documents to return in search results
      • getCursor

        public Cursor getCursor()
        Returns:
        a cursor returned from a previous set of search results to use as a starting point to retrieve the next set of results. Can be null
      • getOffset

        public int getOffset()
        Returns:
        the offset of the first result to return; returns 0 if was not set
      • hasNumberFoundAccuracy

        public boolean hasNumberFoundAccuracy()
        Returns true iff there is an accuracy requirement set.
        Returns:
        the found count accuracy
      • getNumberFoundAccuracy

        public int getNumberFoundAccuracy()
        Any Results.getNumberFound() less than or equal to this setting will be accurate.
        Returns:
        the found count accuracy
      • isReturningIdsOnly

        public boolean isReturningIdsOnly()
        Returns:
        if this search request returns results document IDs only
      • getFieldsToReturn

        public java.util.List<java.lang.String> getFieldsToReturn()
        Returns:
        an unmodifiable list of names of fields to return in search results
      • getFieldsToSnippet

        public java.util.List<java.lang.String> getFieldsToSnippet()
        Returns:
        an unmodifiable list of names of fields to snippet in search results
      • getExpressionsToReturn

        public java.util.List<FieldExpression> getExpressionsToReturn()
        Returns:
        an unmodifiable list of expressions which will be evaluated and returned in results
      • newBuilder

        public static QueryOptions.Builder newBuilder(QueryOptions request)
        Creates a builder from the given request.
        Parameters:
        request - the search request for the builder to use to build another request
        Returns:
        a new builder with values set from the given request
      • toString

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

Send feedback about...