public final class Search extends StageThe 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)
);
Static Methods
withQuery(BooleanExpression query)
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.
| Parameter | |
|---|---|
| Name | Description |
query |
BooleanExpression |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withQuery(String rquery)
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.
| Parameter | |
|---|---|
| Name | Description |
rquery |
String |
| Returns | |
|---|---|
| Type | Description |
Search |
|
Constructors
Search(InternalOptions options)
public Search(InternalOptions options)| Parameter | |
|---|---|
| Name | Description |
options |
com.google.cloud.firestore.pipeline.stages.InternalOptions |
Methods
withAddFields(Selectable field, Selectable[] additionalFields)
public Search withAddFields(Selectable field, Selectable[] additionalFields)Specify the fields to add to each document.
| Parameters | |
|---|---|
| Name | Description |
field |
Selectable |
additionalFields |
Selectable[] |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withLanguageCode(String value)
public Search withLanguageCode(String value)Specify the BCP-47 language code of text in the search query, such as “en” or “sr”.
| Parameter | |
|---|---|
| Name | Description |
value |
String |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withLimit(long limit)
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.
| Parameter | |
|---|---|
| Name | Description |
limit |
long |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withOffset(long offset)
public Search withOffset(long offset)Specify the number of documents to skip from the beginning of the search result set.
| Parameter | |
|---|---|
| Name | Description |
offset |
long |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withRetrievalDepth(long retrievalDepth)
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.
| Parameter | |
|---|---|
| Name | Description |
retrievalDepth |
long |
| Returns | |
|---|---|
| Type | Description |
Search |
|
withSort(Ordering order, Ordering[] additionalOrderings)
public Search withSort(Ordering order, Ordering[] additionalOrderings)Specify how the returned documents are sorted. One or more ordering are required.
| Parameters | |
|---|---|
| Name | Description |
order |
Ordering |
additionalOrderings |
Ordering[] |
| Returns | |
|---|---|
| Type | Description |
Search |
|