Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.appengine.api.search
Class SearchRequest

    java.lang.Object
      com.google.appengine.api.search.SearchRequest

    public final class SearchRequest

extends java.lang.Object

A request to search an index for documents which match a query, restricting the document fields returned to those given, and scoring and sorting the results, whilst supporting pagination.

For example, the following request 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 `SearchResponse` to get the next batch of results after this.

     SearchRequest request = SearchRequest.newBuilder()
          .setQuery("good story")
          .setLimit(20)
          .setFieldsToReturn("author", "date-sent")
          .setFieldsToSnippet("subject", "body")
          .addSortSpec(SortSpec.newBuilder()
              .setExpression("author")
              .setSortDescending(true)
              .setDefaultValue(""))
          .setCursor(responseCursor)
          .setCursorType(CursorType.RESPONSE_CURSOR)
          .build();

Nested Class Summary
`static class` | `SearchRequest.Builder` A builder which constructs SearchRequest objects.
`static class` | `SearchRequest.CursorType` Use a cursor returned from a previous set of search results as a starting point to retrieve the next set of results.

Method Summary
`java.lang.String` | `getCursor()`
`SearchRequest.CursorType` | `getCursorType()`
`java.util.List<FieldExpression>` | `getExpressionsToReturn()`
`java.util.List<java.lang.String>` | `getFieldsToReturn()`
`java.util.List<java.lang.String>` | `getFieldsToSnippet()`
`int` | `getLimit()`
`int` | `getMatchedCountAccuracy()` Any `SearchResponse.getMatchedCount()` less than or equal to this setting will be accurate.
`java.lang.Integer` | `getOffset()`
`java.lang.String` | `getQuery()` 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").
`java.util.List<SortSpec>` | `getSortSpecs()`
`static SearchRequest.Builder` | `newBuilder()` Creates and returns a `SearchRequest` builder.
`static SearchRequest.Builder` | `newBuilder(SearchRequest request)` Creates a builder from the given request.
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getQuery

    public java.lang.String getQuery()

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

  Returns:
    the query

### getLimit

    public int getLimit()

  Returns:
    the limit on the number of documents to return in search results

### getCursor

    public java.lang.String 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 java.lang.Integer getOffset()

  Returns:
    the offset of the first result to return; may be null

### getCursorType

    public SearchRequest.CursorType getCursorType()

  Returns:
    the type of cursor to return with the search results

### getMatchedCountAccuracy

    public int getMatchedCountAccuracy()

  Any `SearchResponse.getMatchedCount()` less than or equal to this setting will be accurate.

  Returns:
    the matched count accuracy

### getSortSpecs

    public java.util.List<SortSpec> getSortSpecs()

  Returns:
    a list of field sorting specifications representing a multi-dimensional sort

### 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 SearchRequest.Builder newBuilder()

  Creates and returns a `SearchRequest` builder. Set the search request parameters and use the `SearchRequest.Builder.build()` method to create a concrete instance of SearchRequest.

  Returns:
    a `SearchRequest.Builder` which can construct a search request

### newBuilder

    public static SearchRequest.Builder newBuilder(SearchRequest request)

  Creates a builder from the given request.

  Parameters:
    `request` - the search request for the builder to use to build another request

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD