Skip to content

CSHARP-5882, CSHARP-5884, and CSHARP-5762#1900

Open
ajcvickers wants to merge 4 commits intomongodb:mainfrom
ajcvickers:CSHARP-5884b
Open

CSHARP-5882, CSHARP-5884, and CSHARP-5762#1900
ajcvickers wants to merge 4 commits intomongodb:mainfrom
ajcvickers:CSHARP-5884b

Conversation

@ajcvickers
Copy link
Contributor

@ajcvickers ajcvickers commented Mar 5, 2026

CSHARP-5882: Support stored source in vector indexes

Allows fields to be included or excluded. Does not allow true to be set because this will always fail for a vector index.

CSHARP-5884: Add new fields for Auto embedding in Atlas Vector search indexes

CSHARP-5762: Vector search against nested embeddings and arrays of embeddings

Copilot AI review requested due to automatic review settings March 5, 2026 10:55
@ajcvickers ajcvickers requested a review from a team as a code owner March 5, 2026 10:55
@ajcvickers ajcvickers requested a review from adelinowona March 5, 2026 10:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for storedSource configuration in vector search indexes, allowing users to specify which fields should be included or excluded from the Atlas vector index's stored source. The implementation deliberately avoids supporting true as a value (which would always fail for vector indexes, per the description).

Changes:

  • Added IncludedStoredFields and ExcludedStoredFields properties and a RenderStoredSource helper method to CreateVectorSearchIndexModelBase<TDocument>.
  • Added WithIncludedStoredFields and WithExcludedStoredFields fluent methods (both field-definition and expression-based overloads) to CreateVectorSearchIndexModel<TDocument> and CreateAutoEmbeddingVectorSearchIndexModel<TDocument>, and updated their Render methods to emit the storedSource BSON.
  • Updated integration tests in AtlasSearchIndexManagmentTests.cs to verify the new stored source behavior, changed the poll period from 5s to 10s, and refactored GetIndexes to accept expectTimeout as an explicit parameter.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/MongoDB.Driver/CreateVectorSearchIndexModelBase.cs Adds IncludedStoredFields, ExcludedStoredFields properties and RenderStoredSource helper; minor doc comment issue
src/MongoDB.Driver/CreateVectorSearchIndexModel.cs Adds WithIncludedStoredFields/WithExcludedStoredFields fluent methods and calls RenderStoredSource in Render
src/MongoDB.Driver/CreateAutoEmbeddingVectorSearchIndexModel.cs Same pattern as CreateVectorSearchIndexModel.cs for auto-embedding variant
tests/MongoDB.Driver.Tests/Search/AtlasSearchIndexManagmentTests.cs Integration tests for new storedSource behavior; poll period, expectTimeout refactor, minor naming/formatting issues

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ajcvickers ajcvickers changed the title CSHARP-5884: Support stored source in vector indexes CSHARP-5882: Support stored source in vector indexes Mar 5, 2026
@ajcvickers ajcvickers added the feature Adds new user-facing functionality. label Mar 5, 2026
@ajcvickers ajcvickers changed the title CSHARP-5882: Support stored source in vector indexes CSHARP-5882 and CSHARP-5884 Mar 5, 2026
@ajcvickers ajcvickers requested a review from Copilot March 5, 2026 12:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

tests/MongoDB.Driver.Tests/Search/AtlasSearchIndexManagmentTests.cs:578

  • Lines 570-572 assert that numDimensions, similarity, and quantization exist in the indexField document with specific values, but lines 576-578 immediately assert those same fields do NOT exist (Should().Be(false)). This is a direct contradiction — both sets of assertions cannot be true at the same time. Lines 576-578 appear to be leftover from the "required only options" test (which copied the pattern of asserting optional fields are absent) and should be removed since this test explicitly configures all those options.
            indexField.Contains("quantization").Should().Be(false);
            indexField.Contains("numDimensions").Should().Be(false);
            indexField.Contains("similarity").Should().Be(false);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ajcvickers ajcvickers force-pushed the CSHARP-5884b branch 2 times, most recently from e81af22 to 8b0ebd1 Compare March 5, 2026 13:23
@ajcvickers
Copy link
Contributor Author

Verified Evergreen failure not due to this PR.

@codeowners-service-app
Copy link

codeowners-service-app bot commented Mar 9, 2026

Assigned jordan-smith721 for team dbx-csharp-dotnet because adelinowona is out of office.
Assigned jordan-smith721 for team dbx-csharp-dotnet because adelinowona is out of office.

@ajcvickers ajcvickers changed the title CSHARP-5882 and CSHARP-5884 CSHARP-5882, CSHARP-5884, and CSHARP-5762 Mar 9, 2026
@ajcvickers ajcvickers requested a review from Copilot March 9, 2026 11:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/MongoDB.Driver.Tests/Search/AtlasSearchIndexManagmentTests.cs:689

  • In Can_create_autoEmbed_vector_index_for_all_options, lines 681–685 assert that indexField["numDimensions"], indexField["similarity"], and indexField["quantization"] exist with specific values, but then lines 687–689 immediately assert that the same fields do NOT exist (.Should().Be(false)). These assertions directly contradict each other and the test will always fail at the last three assertions (or would never actually validate the first set correctly). The three negative assertions at lines 687–689 appear to be leftover copy-paste from the Can_create_autoEmbed_vector_index_for_required_only_options test, which correctly validates the absence of those optional fields. They should be removed from the all-options test.
            indexField.Contains("quantization").Should().Be(false);
            indexField.Contains("numDimensions").Should().Be(false);
            indexField.Contains("similarity").Should().Be(false);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ajcvickers ajcvickers force-pushed the CSHARP-5884b branch 2 times, most recently from 0fc36f8 to ba7ec4d Compare March 9, 2026 12:27
@sanych-sun sanych-sun removed the request for review from jordan-smith721 March 9, 2026 18:49
Comment on lines +155 to +157
var quantizationValue = Quantization == VectorQuantization.BinaryNoRescore
? "binaryNoRescore"
: Quantization?.ToString().ToLowerInvariant();
Copy link
Contributor

@adelinowona adelinowona Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateVectorSearchIndexModelBase is shared by both vector indexes and auto-embedding indexes and the same rendering logic here applies to both right? For auto-embedding indexes, rendering "none" is probably wrong based on the syntax document linked in the drivers ticket for the 5884 ticket. I suppose Atlas might an error in this case but not sure if the error is informative to the user, in which case we might have to throw ourselves and inform the server team to improve their error messaging. I'll defer to you to check this as I presume you have an environment set up for testing all this search changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will fix.

Comment on lines +2186 to +2190
if (nestedRoot != null && options?.NestedFilter != null)
{
vectorSearchOperator.Add("filter", options.NestedFilter.Render(
(args with { SubPathRoot = nestedRoot }) with { RenderDollarForm = true }));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user sets NestedFilter but the vector field path is NOT nested (e.g., "Embedding" instead of "Plot.Embedding"), this condition fails silently and the filter gets ignored with no warning. Should we make sure NestedFilter can only be used when the vector field path is nested? Or does the server throw an informative error in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would be better to explicitly throw in this case. Will fix.

params FieldDefinition<TDocument>[] filterFields)
: base(name, SearchIndexType.VectorSearch)
{
Field = field;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this field parameter be validated to not be null? I know it doesn't makes sense for anyone using this to ever pass a null here but it doesn't hurt to be defensive. In any case, I'll defer to your judgement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@ajcvickers ajcvickers requested a review from adelinowona March 17, 2026 11:08
@jordan-smith721 jordan-smith721 removed their request for review March 17, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds new user-facing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants