java.lang.Object
com.google.cloud.firestore.pipeline.stages.Stage
com.google.cloud.firestore.pipeline.stages.Search

@BetaApi public final class Search extends Stage
The Search stage executes full-text search or geo search operations.

The Search stage must be the first stage in a Pipeline.

Example:


 db.pipeline().collection("restaurants").search(
   Search.withQuery(documentMatches("waffles OR pancakes"))
     .withSort(score().descending())
     .withLimit(10)
 );
 
  • Constructor Details

    • Search

      @InternalApi public Search(com.google.cloud.firestore.pipeline.stages.InternalOptions options)
  • Method Details

    • withQuery

      public static Search withQuery(BooleanExpression query)
      Create Search with an expression search query.

      query specifies the search query that will be used to query and score documents by the search stage.

    • withQuery

      public static Search withQuery(String rquery)
      Create Search with an expression search query.

      query specifies the search query that will be used to query and score documents by the search stage.

    • withAddFields

      public Search withAddFields(Selectable field, Selectable... additionalFields)
      Specify the fields to add to each document.
    • withSort

      public Search withSort(Ordering order, Ordering... additionalOrderings)
      Specify how the returned documents are sorted. One or more ordering are required.
    • withLimit

      public Search withLimit(long limit)
      Specify the maximum number of documents to return from the `search` stage. The `limit` is applied after documents are scored and sorted.
    • withRetrievalDepth

      public Search withRetrievalDepth(long retrievalDepth)
      Specify the maximum number of documents to retrieve from the search index. Documents will be retrieved in the pre-sort order specified by the search index. The `retrievalDepth` is a limit applied before documents are scored and sorted, which can reduce costs of expensive scoring and sorting operations.
    • withOffset

      public Search withOffset(long offset)
      Specify the number of documents to skip from the beginning of the search result set.
    • withLanguageCode

      public Search withLanguageCode(String value)
      Specify the BCP-47 language code of text in the search query, such as “en” or “sr”.