-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add storedSource support for vector search indexes and returnStoredSource for $vectorSearch queries #1977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add storedSource support for vector search indexes and returnStoredSource for $vectorSearch queries #1977
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,16 @@ public interface VectorSearchOptions extends Bson { | |
| */ | ||
| VectorSearchOptions filter(Bson filter); | ||
|
|
||
| /** | ||
| * Creates a new {@link VectorSearchOptions} that instructs to return only stored source fields. | ||
| * | ||
| * @param returnStoredSource The option to return only stored source fields. | ||
| * @return A new {@link VectorSearchOptions}. | ||
| * @mongodb.atlas.manual atlas-vector-search/vector-search-stage/ $vectorSearch | ||
| * @since 5.8 | ||
| */ | ||
| VectorSearchOptions returnStoredSource(boolean returnStoredSource); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you think it's better to make it
|
||
|
|
||
| /** | ||
| * Creates a new {@link VectorSearchOptions} with the specified option in situations when there is no builder method | ||
| * that better satisfies your needs. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,20 @@ class SearchIndexDefinitionSpec extends BaseSpec { | |
| ) | ||
| } | ||
|
|
||
| it should "create a vectorSearch definition with storedSource" in { | ||
| toBson( | ||
| vectorSearch( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just curios , why do we also add scala tests when it uses existing java classes that we already unit tested ? |
||
| vectorField("embedding").numDimensions(1536).similarity("cosine") | ||
| ).storedSource(Document("include" -> List("plot", "title"))) | ||
| ) should equal( | ||
| Document( | ||
| """{"fields": [ | ||
| |{"type": "vector", "path": "embedding", "numDimensions": 1536, "similarity": "cosine"} | ||
| |], "storedSource": {"include": ["plot", "title"]}}""".stripMargin.replaceAll("\n", " ") | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| it should "create a SearchIndexModel with VectorSearchIndexDefinition" in { | ||
| val definition = vectorSearch( | ||
| vectorField("embedding").numDimensions(1536).similarity("cosine") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.