Skip to content

Commit 6c94757

Browse files
committed
add geo and search sort snippet
1 parent 1c38943 commit 6c94757

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

firestore-temp/test.firestore.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ describe("firestore-pipelines", () => {
2828
variable,
2929
documentMatches,
3030
score,
31+
matches,
32+
snippet,
33+
geoDistance,
3134
exists,
3235
not,
3336
currentTimestamp
@@ -2373,4 +2376,27 @@ describe("firestore-pipelines", () => {
23732376
await pipeline.execute();
23742377
// [END delete_dml]
23752378
}
2379+
2380+
async function searchScoreSort() {
2381+
// [START search_score_sort]
2382+
const result = await db.pipeline().collection('restaurants')
2383+
.search({
2384+
query: documentMatches('waffles'),
2385+
sort: score().descending()
2386+
})
2387+
.execute();
2388+
// [END search_score_sort]
2389+
console.log(result);
2390+
}
2391+
2392+
async function geospatialSearch() {
2393+
// [START geospatial_search]
2394+
const result = await db.pipeline().collection('restaurants')
2395+
.search({
2396+
query: documentMatches('"belgian waffles"')
2397+
})
2398+
.execute();
2399+
// [END geospatial_search]
2400+
console.log(result);
2401+
}
23762402
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-temp/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START geospatial_search_modular]
8+
const result = await db.pipeline().collection('restaurants')
9+
.search({
10+
query: documentMatches('"belgian waffles"')
11+
})
12+
.execute();
13+
// [END geospatial_search_modular]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This snippet file was generated by processing the source file:
2+
// ./firestore-temp/test.firestore.js
3+
//
4+
// To update the snippets in this file, edit the source and then run
5+
// 'npm run snippets'.
6+
7+
// [START search_score_sort_modular]
8+
const result = await db.pipeline().collection('restaurants')
9+
.search({
10+
query: documentMatches('waffles'),
11+
sort: score().descending()
12+
})
13+
.execute();
14+
// [END search_score_sort_modular]

0 commit comments

Comments
 (0)