Skip to content

Commit

Permalink
Updated sample for findNearest documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkDuckworth committed Aug 14, 2024
1 parent a042509 commit 6ccf5ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dev/src/reference/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,14 @@ export class Query<
* @example
* ```
* // Returns the closest 10 documents whose Euclidean distance from their 'embedding' fields are closed to [41, 42].
* const vectorQuery = col.findNearest('embedding', [41, 42], 10, 'EUCLIDEAN', { distanceResultField: 'distance'});
* const vectorQuery = col.findNearest({
* vectorField: 'embedding',
* queryVector: [41, 42],
* limit: 10,
* distanceMeasure: 'EUCLIDEAN',
* distanceResultField: 'distance',
* distanceThreshold: 0.125
* });
*
* const querySnapshot = await aggregateQuery.get();
* querySnapshot.forEach(...);
Expand Down
9 changes: 8 additions & 1 deletion types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,14 @@ declare namespace FirebaseFirestore {
* @example
* ```
* // Returns the closest 10 documents whose Euclidean distance from their 'embedding' fields are closed to [41, 42].
* const vectorQuery = col.findNearest('embedding', [41, 42], 10, 'EUCLIDEAN', { distanceResultField: 'distance'});
* const vectorQuery = col.findNearest({
* vectorField: 'embedding',
* queryVector: [41, 42],
* limit: 10,
* distanceMeasure: 'EUCLIDEAN',
* distanceResultField: 'distance',
* distanceThreshold: 0.125
* });
*
* const querySnapshot = await aggregateQuery.get();
* querySnapshot.forEach(...);
Expand Down

0 comments on commit 6ccf5ae

Please sign in to comment.