-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement $vectorSearch stage builder
- Loading branch information
Showing
8 changed files
with
504 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ tests: | |
- | ||
$project: | ||
_id: 0 | ||
title: 1 | ||
title: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ tests: | |
- | ||
$project: | ||
_id: 0 | ||
title: 1 | ||
title: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# $schema: ../schema.json | ||
name: $vectorSearch | ||
link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/' | ||
type: | ||
- stage | ||
encode: object | ||
description: | | ||
Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). | ||
arguments: | ||
- | ||
name: index | ||
type: | ||
- string | ||
- | ||
name: limit | ||
type: | ||
- int | ||
- | ||
name: path | ||
type: | ||
- searchPath | ||
- | ||
name: queryVector | ||
type: | ||
- array # of numbers | ||
- | ||
name: exact | ||
optional: true | ||
type: | ||
- bool | ||
- | ||
name: filter | ||
optional: true | ||
type: | ||
- query | ||
- | ||
name: numCandidates | ||
optional: true | ||
type: | ||
- int | ||
tests: | ||
- | ||
name: 'ANN Basic' | ||
link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' | ||
pipeline: | ||
- | ||
$vectorSearch: | ||
index: 'vector_index' | ||
path: 'plot_embedding' | ||
queryVector: | ||
- -0.0016261312 | ||
- -0.028070757 | ||
- -0.011342932 | ||
# skip other numbers, not relevant to the test | ||
numCandidates: 150 | ||
limit: 10 | ||
- | ||
$project: | ||
_id: 0 | ||
plot: 1 | ||
title: 1 | ||
score: | ||
$meta: 'vectorSearchScore' | ||
|
||
- | ||
name: 'ANN Filter' | ||
link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' | ||
pipeline: | ||
- | ||
$vectorSearch: | ||
index: 'vector_index' | ||
path: 'plot_embedding' | ||
filter: | ||
$and: | ||
- | ||
year: | ||
$lt: 1975 | ||
queryVector: | ||
- 0.02421053 | ||
- -0.022372592 | ||
- -0.006231137 | ||
# skip other numbers, not relevant to the test | ||
numCandidates: 150 | ||
limit: 10 | ||
- | ||
$project: | ||
_id: 0 | ||
title: 1 | ||
plot: 1 | ||
year: 1 | ||
score: | ||
$meta: 'vectorSearchScore' | ||
|
||
- | ||
name: 'ENN' | ||
link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples' | ||
pipeline: | ||
- | ||
$vectorSearch: | ||
index: 'vector_index' | ||
path: 'plot_embedding' | ||
queryVector: | ||
- -0.006954097 | ||
- -0.009932499 | ||
- -0.001311474 | ||
# skip other numbers, not relevant to the test | ||
exact: true | ||
limit: 10 | ||
- | ||
$project: | ||
_id: 0 | ||
plot: 1 | ||
title: 1 | ||
score: | ||
$meta: 'vectorSearchScore' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.