Skip to content

Commit 31bddcd

Browse files
feat(firestore): add public preview support for full-text search and geo search (#9734)
--------- Co-authored-by: Daniel La Rocque <[email protected]>
1 parent 620c8ca commit 31bddcd

27 files changed

Lines changed: 3064 additions & 377 deletions

.changeset/happy-bugs-attack.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"firebase": minor
3+
"@firebase/firestore": minor
4+
---
5+
6+
Added public preview support for full-text and geo search in Pipelines.

common/api-review/firestore-lite-pipelines.api.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ export function documentId(documentPath: string | DocumentReference): FunctionEx
399399
// @public
400400
export function documentId(documentPathExpr: Expression): FunctionExpression;
401401

402+
// @beta
403+
export function documentMatches(rquery: string | Expression): BooleanExpression;
404+
402405
// @public
403406
export type DocumentsStageOptions = StageOptions & {
404407
docs: Array<string | DocumentReference>;
@@ -834,6 +837,8 @@ export class Field extends Expression implements Selectable {
834837
readonly expressionType: ExpressionType;
835838
// (undocumented)
836839
get fieldName(): string;
840+
// @beta
841+
geoDistance(location: GeoPoint | Expression): Expression;
837842
// (undocumented)
838843
selectable: true;
839844
}
@@ -868,11 +873,13 @@ export function floor(fieldName: string): FunctionExpression;
868873
// @public
869874
export class FunctionExpression extends Expression {
870875
constructor(name: string, params: Expression[]);
871-
constructor(name: string, params: Expression[], _methodName: string | undefined);
872876
// (undocumented)
873877
readonly expressionType: ExpressionType;
874878
}
875879

880+
// @beta
881+
export function geoDistance(fieldName: string | Field, location: GeoPoint | Expression): Expression;
882+
876883
// @public
877884
export function greaterThan(left: Expression, right: Expression): BooleanExpression;
878885

@@ -1212,6 +1219,8 @@ export class Pipeline {
12121219
replaceWith(options: ReplaceWithStageOptions): Pipeline;
12131220
sample(documents: number): Pipeline;
12141221
sample(options: SampleStageOptions): Pipeline;
1222+
// @beta
1223+
search(options: SearchStageOptions): Pipeline;
12151224
select(selection: Selectable | string, ...additionalSelections: Array<Selectable | string>): Pipeline;
12161225
select(options: SelectStageOptions): Pipeline;
12171226
sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline;
@@ -1376,6 +1385,16 @@ export type SampleStageOptions = StageOptions & OneOf<{
13761385
documents: number;
13771386
}>;
13781387

1388+
// @beta
1389+
export function score(): Expression;
1390+
1391+
// @beta
1392+
export type SearchStageOptions = StageOptions & {
1393+
query: BooleanExpression | string;
1394+
sort?: Ordering | Ordering[];
1395+
addFields?: Selectable[];
1396+
};
1397+
13791398
// @public
13801399
export interface Selectable {
13811400
// (undocumented)
@@ -1411,11 +1430,11 @@ export function sqrt(expression: Expression): FunctionExpression;
14111430
export function sqrt(fieldName: string): FunctionExpression;
14121431

14131432
// @public
1414-
export interface StageOptions {
1433+
export type StageOptions = {
14151434
rawOptions?: {
14161435
[name: string]: unknown;
14171436
};
1418-
}
1437+
};
14191438

14201439
// @public
14211440
export function startsWith(fieldName: string, prefix: string): BooleanExpression;

common/api-review/firestore-pipelines.api.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ export function documentId(documentPath: string | DocumentReference): FunctionEx
399399
// @public
400400
export function documentId(documentPathExpr: Expression): FunctionExpression;
401401

402+
// @beta
403+
export function documentMatches(rquery: string | Expression): BooleanExpression;
404+
402405
// @public
403406
export type DocumentsStageOptions = StageOptions & {
404407
docs: Array<string | DocumentReference>;
@@ -837,6 +840,8 @@ export class Field extends Expression implements Selectable {
837840
readonly expressionType: ExpressionType;
838841
// (undocumented)
839842
get fieldName(): string;
843+
// @beta
844+
geoDistance(location: GeoPoint | Expression): Expression;
840845
// (undocumented)
841846
selectable: true;
842847
}
@@ -871,11 +876,13 @@ export function floor(fieldName: string): FunctionExpression;
871876
// @public
872877
export class FunctionExpression extends Expression {
873878
constructor(name: string, params: Expression[]);
874-
constructor(name: string, params: Expression[], _methodName: string | undefined);
875879
// (undocumented)
876880
readonly expressionType: ExpressionType;
877881
}
878882

883+
// @beta
884+
export function geoDistance(fieldName: string | Field, location: GeoPoint | Expression): Expression;
885+
879886
// @public
880887
export function greaterThan(left: Expression, right: Expression): BooleanExpression;
881888

@@ -1219,6 +1226,10 @@ export class Pipeline {
12191226
replaceWith(options: ReplaceWithStageOptions): Pipeline;
12201227
sample(documents: number): Pipeline;
12211228
sample(options: SampleStageOptions): Pipeline;
1229+
// Warning: (ae-incompatible-release-tags) The symbol "search" is marked as @public, but its signature references "SearchStageOptions" which is marked as @beta
1230+
//
1231+
// (undocumented)
1232+
search(options: SearchStageOptions): Pipeline;
12221233
select(selection: Selectable | string, ...additionalSelections: Array<Selectable | string>): Pipeline;
12231234
select(options: SelectStageOptions): Pipeline;
12241235
sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline;
@@ -1398,6 +1409,16 @@ export type SampleStageOptions = StageOptions & OneOf<{
13981409
documents: number;
13991410
}>;
14001411

1412+
// @beta
1413+
export function score(): Expression;
1414+
1415+
// @beta
1416+
export type SearchStageOptions = StageOptions & {
1417+
query: BooleanExpression | string;
1418+
sort?: Ordering | Ordering[];
1419+
addFields?: Selectable[];
1420+
};
1421+
14011422
// @public
14021423
export interface Selectable {
14031424
// (undocumented)
@@ -1433,11 +1454,11 @@ export function sqrt(expression: Expression): FunctionExpression;
14331454
export function sqrt(fieldName: string): FunctionExpression;
14341455

14351456
// @public
1436-
export interface StageOptions {
1457+
export type StageOptions = {
14371458
rawOptions?: {
14381459
[name: string]: unknown;
14391460
};
1440-
}
1461+
};
14411462

14421463
// @public
14431464
export function startsWith(fieldName: string, prefix: string): BooleanExpression;

docs-devsite/_toc.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,6 @@ toc:
654654
path: /docs/reference/js/firestore_lite_pipelines.querydocumentsnapshot.md
655655
- title: Selectable
656656
path: /docs/reference/js/firestore_lite_pipelines.selectable.md
657-
- title: StageOptions
658-
path: /docs/reference/js/firestore_lite_pipelines.stageoptions.md
659657
- title: Timestamp
660658
path: /docs/reference/js/firestore_lite_pipelines.timestamp.md
661659
- title: VectorValue
@@ -719,8 +717,6 @@ toc:
719717
path: /docs/reference/js/firestore_pipelines.snapshotmetadata.md
720718
- title: SnapshotOptions
721719
path: /docs/reference/js/firestore_pipelines.snapshotoptions.md
722-
- title: StageOptions
723-
path: /docs/reference/js/firestore_pipelines.stageoptions.md
724720
- title: Timestamp
725721
path: /docs/reference/js/firestore_pipelines.timestamp.md
726722
- title: VectorValue

docs-devsite/firestore_lite_pipelines.field.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export declare class Field extends Expression implements Selectable
3535
| [fieldName](./firestore_lite_pipelines.field.md#fieldfieldname) | | string | |
3636
| [selectable](./firestore_lite_pipelines.field.md#fieldselectable) | | true | |
3737
38+
## Methods
39+
40+
| Method | Modifiers | Description |
41+
| --- | --- | --- |
42+
| [geoDistance(location)](./firestore_lite_pipelines.field.md#fieldgeodistance) | | <b><i>(Public Preview)</i></b> Evaluates to the distance in meters between the location specified by this field and the query location. |
43+
3844
## Field.alias
3945
4046
<b>Signature:</b>
@@ -75,6 +81,31 @@ get fieldName(): string;
7581
selectable: true;
7682
```
7783
84+
## Field.geoDistance()
85+
86+
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
87+
>
88+
89+
Evaluates to the distance in meters between the location specified by this field and the query location.
90+
91+
This Expression can only be used within a `Search` stage.
92+
93+
<b>Signature:</b>
94+
95+
```typescript
96+
geoDistance(location: GeoPoint | Expression): Expression;
97+
```
98+
99+
#### Parameters
100+
101+
| Parameter | Type | Description |
102+
| --- | --- | --- |
103+
| location | [GeoPoint](./firestore_lite.geopoint.md#geopoint_class) \| [Expression](./firestore_lite_pipelines.expression.md#expression_class) | Compute distance to this GeoPoint. |
104+
105+
<b>Returns:</b>
106+
107+
[Expression](./firestore_lite_pipelines.expression.md#expression_class)
108+
78109
### Example
79110
80111

docs-devsite/firestore_lite_pipelines.functionexpression.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export declare class FunctionExpression extends Expression
2626
| Constructor | Modifiers | Description |
2727
| --- | --- | --- |
2828
| [(constructor)(name, params)](./firestore_lite_pipelines.functionexpression.md#functionexpressionconstructor) | | Constructs a new instance of the <code>FunctionExpression</code> class |
29-
| [(constructor)(name, params, \_methodName)](./firestore_lite_pipelines.functionexpression.md#functionexpressionconstructor) | | Constructs a new instance of the <code>FunctionExpression</code> class |
3029
3130
## Properties
3231
@@ -51,24 +50,6 @@ constructor(name: string, params: Expression[]);
5150
| name | string | |
5251
| params | [Expression](./firestore_lite_pipelines.expression.md#expression_class)<!-- -->\[\] | |
5352
54-
## FunctionExpression.(constructor)
55-
56-
Constructs a new instance of the `FunctionExpression` class
57-
58-
<b>Signature:</b>
59-
60-
```typescript
61-
constructor(name: string, params: Expression[], _methodName: string | undefined);
62-
```
63-
64-
#### Parameters
65-
66-
| Parameter | Type | Description |
67-
| --- | --- | --- |
68-
| name | string | |
69-
| params | [Expression](./firestore_lite_pipelines.expression.md#expression_class)<!-- -->\[\] | |
70-
| \_methodName | string \| undefined | |
71-
7253
## FunctionExpression.expressionType
7354
7455
<b>Signature:</b>

0 commit comments

Comments
 (0)