Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 41c12ca

Browse files
committed
ref doc cleanup
1 parent 1c97c79 commit 41c12ca

2 files changed

Lines changed: 62 additions & 8 deletions

File tree

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,14 @@ public static Expression geoDistance(String fieldName, GeoPoint location) {
34123412
*
34133413
* <p>This Expression can only be used within a {@code Search} stage.
34143414
*
3415+
* <p>Example:
3416+
*
3417+
* <pre>{@code
3418+
* db.pipeline().collection("restaurants").search(
3419+
* Search.withQuery("waffles").withSort(geoDistance(field("location"), new GeoPoint(37.0, -122.0)).ascending())
3420+
* )
3421+
* }</pre>
3422+
*
34153423
* @param field Specifies the field in the document which contains the first {@link GeoPoint} for
34163424
* distance computation.
34173425
* @param location Compute distance to this {@link GeoPoint}.
@@ -3428,7 +3436,13 @@ public static Expression geoDistance(Field field, GeoPoint location) {
34283436
*
34293437
* <p>This Expression can only be used within a {@code Search} stage.
34303438
*
3431-
* @param rquery Define the search query using the search DTS.
3439+
* <p>Example:
3440+
*
3441+
* <pre>{@code
3442+
* db.pipeline().collection("restaurants").search(Search.withQuery(documentMatches("waffles OR pancakes")))
3443+
* }</pre>
3444+
*
3445+
* @param rquery Define the search query using the search DSL.
34323446
* @return A new {@link BooleanExpression} representing the documentMatches operation.
34333447
*/
34343448
@BetaApi
@@ -3441,8 +3455,14 @@ public static BooleanExpression documentMatches(String rquery) {
34413455
*
34423456
* <p>This Expression can only be used within a {@code Search} stage.
34433457
*
3458+
* <p>Example:
3459+
*
3460+
* <pre>{@code
3461+
* db.pipeline().collection("restaurants").search(Search.withQuery(matches("menu", "waffles")))
3462+
* }</pre>
3463+
*
34443464
* @param fieldName Perform search on this field.
3445-
* @param rquery Define the search query using the rquery DTS.
3465+
* @param rquery Define the search query using the search DSL.
34463466
*/
34473467
@InternalApi
34483468
static BooleanExpression matches(String fieldName, String rquery) {
@@ -3455,7 +3475,7 @@ static BooleanExpression matches(String fieldName, String rquery) {
34553475
* <p>This Expression can only be used within a {@code Search} stage.
34563476
*
34573477
* @param field Perform search on this field.
3458-
* @param rquery Define the search query using the rquery DTS.
3478+
* @param rquery Define the search query using the search DSL.
34593479
*/
34603480
@InternalApi
34613481
static BooleanExpression matches(Field field, String rquery) {
@@ -3464,10 +3484,18 @@ static BooleanExpression matches(Field field, String rquery) {
34643484

34653485
/**
34663486
* Evaluates to the search score that reflects the topicality of the document to all of the text
3467-
* predicates ({@code matches} and {@code documentMatches}) in the search query.
3487+
* predicates (for example: {@code documentMatches}) in the search query.
34683488
*
34693489
* <p>This Expression can only be used within a {@code Search} stage.
34703490
*
3491+
* <p>Example:
3492+
*
3493+
* <pre>{@code
3494+
* db.pipeline().collection("restaurants").search(
3495+
* Search.withQuery("waffles").withSort(score().descending())
3496+
* )
3497+
* }</pre>
3498+
*
34713499
* @return A new {@link Expression} representing the score operation.
34723500
*/
34733501
@BetaApi
@@ -3481,8 +3509,16 @@ public static Expression score() {
34813509
*
34823510
* <p>This Expression can only be used within a {@code Search} stage.
34833511
*
3512+
* <p>Example:
3513+
*
3514+
* <pre>{@code
3515+
* db.pipeline().collection("restaurants").search(
3516+
* Search.withQuery("waffles").withAddFields(snippet("menu", "waffles").as("snippet"))
3517+
* )
3518+
* }</pre>
3519+
*
34843520
* @param fieldName Search the specified field for matching terms.
3485-
* @param rquery Define the search query using the search DTS.
3521+
* @param rquery Define the search query using the search DSL.
34863522
* @return A new {@link Expression} representing the snippet operation.
34873523
*/
34883524
@BetaApi
@@ -3497,7 +3533,15 @@ public static Expression snippet(String fieldName, String rquery) {
34973533
*
34983534
* <p>This Expression can only be used within a {@code Search} stage.
34993535
*
3500-
* @param rquery Define the search query using the search DTS.
3536+
* <p>Example:
3537+
*
3538+
* <pre>{@code
3539+
* db.pipeline().collection("restaurants").search(
3540+
* Search.withQuery("waffles").withAddFields(field("menu").snippet("waffles").as("snippet"))
3541+
* )
3542+
* }</pre>
3543+
*
3544+
* @param rquery Define the search query using the search DSL.
35013545
* @return A new {@link Expression} representing the snippet operation.
35023546
*/
35033547
@BetaApi

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Search.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
* The Search stage executes full-text search or geo search operations.
3838
*
3939
* <p>The Search stage must be the first stage in a Pipeline.
40+
*
41+
* <p>Example:
42+
*
43+
* <pre>{@code
44+
* db.pipeline().collection("restaurants").search(
45+
* Search.withQuery(documentMatches("waffles OR pancakes"))
46+
* .withSort(score().descending())
47+
* .withLimit(10)
48+
* );
49+
* }</pre>
4050
*/
4151
@BetaApi
4252
public final class Search extends Stage {
@@ -141,8 +151,8 @@ public Search withLimit(long limit) {
141151
}
142152

143153
/**
144-
* Specify the maximum number of documents for the search stage to score. Documents will be
145-
* processed in the pre-sort order specified by the search index.
154+
* Specify the maximum number of documents to retrieve. Documents will be retrieved in the
155+
* pre-sort order specified by the search index.
146156
*/
147157
public Search withRetrievalDepth(long retrievalDepth) {
148158
return new Search(options.with("retrieval_depth", encodeValue(retrievalDepth)));

0 commit comments

Comments
 (0)