Skip to content

Commit 7feca57

Browse files
committed
PR feedback - refdoc and comment cleanup
1 parent af99c22 commit 7feca57

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

handwritten/firestore/dev/src/pipelines/expression.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,11 +3593,23 @@ export class Field
35933593
// }
35943594

35953595
/**
3596+
* @beta
3597+
*
35963598
* Evaluates to the distance in meters between the location specified
35973599
* by this field and the query location.
35983600
*
35993601
* @remarks This Expression can only be used within a `Search` stage.
36003602
*
3603+
* @example
3604+
* ```typescript
3605+
* const geoDistanceToUser = field('location').geoDistance(new GeoPoint(39.7541, -105.0002));
3606+
*
3607+
* db.pipeline().collection('restaurants').search({
3608+
* query: geoDistanceToUser.lessThanOrEqual(2000),
3609+
* sort: geoDistanceToUser.ascending()
3610+
* })
3611+
* ```
3612+
*
36013613
* @param location - Compute distance to this GeoPoint.
36023614
* @returns An `Expression` representing the geoDistance function.
36033615
*/
@@ -10991,8 +11003,8 @@ export function documentMatches(
1099111003
*
1099211004
* Evaluates to the search score that reflects the topicality of the document
1099311005
* to all the text predicates (for example: `documentMatches`)
10994-
* in the search query. If `SearchOptions.query` is not set or does not contain
10995-
* any text predicates, then this score will always be `0`.
11006+
* in the search `query` provided to the `search` stage. If the `query` provided to the search stage
11007+
* is not set or does not contain any text predicates, then this score will always be `0`.
1099611008
*
1099711009
* @remarks This Expression can only be used within a `Search` stage.
1099811010
*

handwritten/firestore/dev/src/pipelines/pipelines.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,13 @@ export class Pipeline implements firestore.Pipelines.Pipeline {
14221422
* @remarks This must be the first stage of the pipeline.
14231423
* @remarks A limited set of expressions are supported in the search stage.
14241424
*
1425+
* @example
1426+
* ```typescript
1427+
* db.pipeline().collection('restaurants').search({
1428+
* query: documentMatches('breakfast')
1429+
* })
1430+
* ```
1431+
*
14251432
* @param options - An object that specifies required and optional parameters
14261433
* for the stage.
14271434
* @return A new `Pipeline` object with this stage appended to the stage list.
@@ -1431,6 +1438,7 @@ export class Pipeline implements firestore.Pipelines.Pipeline {
14311438
const normalizedQuery: BooleanExpression = isExpr(options.query)
14321439
? (options.query as BooleanExpression)
14331440
: documentMatches(options.query);
1441+
// TODO(search) - re-enable select normalization when select is supported in the API
14341442
// const normalizedSelect: Record<string, Expression> | undefined =
14351443
// options.select ? selectablesToObject(options.select) : undefined;
14361444
const normalizedAddFields: Record<string, Expression> | undefined =
@@ -1442,6 +1450,7 @@ export class Pipeline implements firestore.Pipelines.Pipeline {
14421450
const internalOptions: InternalSearchStageOptions = {
14431451
...options,
14441452
query: normalizedQuery,
1453+
// TODO(search) - re-enable select normalization when select is supported in the API
14451454
// select: normalizedSelect,
14461455
addFields: normalizedAddFields,
14471456
sort: normalizedSort,

handwritten/firestore/types/firestore.d.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6073,6 +6073,16 @@ declare namespace FirebaseFirestore {
60736073
*
60746074
* @remarks This Expression can only be used within a `Search` stage.
60756075
*
6076+
* @example
6077+
* ```typescript
6078+
* const geoDistanceToUser = field('location').geoDistance(new GeoPoint(39.7541, -105.0002));
6079+
*
6080+
* db.pipeline().collection('restaurants').search({
6081+
* query: geoDistanceToUser.lessThanOrEqual(2000),
6082+
* sort: geoDistanceToUser.ascending()
6083+
* })
6084+
* ```
6085+
*
60766086
* @param location - Compute distance to this GeoPoint.
60776087
*/
60786088
geoDistance(location: GeoPoint | Expression): Expression;
@@ -13207,6 +13217,26 @@ declare namespace FirebaseFirestore {
1320713217
* @returns A new {@code Pipeline} object with this stage appended to the stage list.
1320813218
*/
1320913219
unnest(options: UnnestStageOptions): Pipeline;
13220+
/**
13221+
* @beta
13222+
*
13223+
* Add a search stage to the Pipeline.
13224+
*
13225+
* @remarks This must be the first stage of the pipeline.
13226+
* @remarks A limited set of expressions are supported in the search stage.
13227+
*
13228+
* @example
13229+
* ```typescript
13230+
* db.pipeline().collection('restaurants').search({
13231+
* query: documentMatches('breakfast')
13232+
* })
13233+
* ```
13234+
*
13235+
* @param options - An object that specifies required and optional parameters
13236+
* for the stage.
13237+
* @return A new `Pipeline` object with this stage appended to the stage list.
13238+
*/
13239+
search(options: SearchStageOptions): Pipeline;
1321013240
/**
1321113241
* @beta
1321213242
* Sorts the documents from previous stages based on one or more `Ordering` criteria.
@@ -13758,7 +13788,7 @@ declare namespace FirebaseFirestore {
1375813788
* @example
1375913789
* ```typescript
1376013790
* db.pipeline().collection('restaurants').search({
13761-
* query: documentMatches("breakfast")
13791+
* query: documentMatches('breakfast')
1376213792
* })
1376313793
* ```
1376413794
*

0 commit comments

Comments
 (0)