Skip to content

Conversation

ajcvickers
Copy link
Contributor

Replaces #1769

@ajcvickers ajcvickers requested a review from rstam October 17, 2025 11:30
@ajcvickers ajcvickers requested a review from a team as a code owner October 17, 2025 11:30
@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 11:30
Copy link

@Copilot 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 typed builders for creating vector indexes in MongoDB Atlas, providing a strongly-typed C# API as an alternative to manually constructing BsonDocument definitions. The changes introduce new enums for vector similarity and quantization, a base class for index models, and a generic CreateVectorIndexModel<TDocument> class that leverages C# expressions for field selection.

Key changes:

  • Adds VectorSimilarity and VectorQuantization enums to represent vector search configuration options
  • Introduces CreateSearchIndexModelBase abstract class and refactors CreateSearchIndexModel to inherit from it
  • Implements CreateVectorIndexModel<TDocument> for type-safe vector index creation with support for filter fields and HNSW options

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/MongoDB.Driver/VectorSimilarity.cs Defines enum for vector similarity functions (Euclidean, Cosine, DotProduct)
src/MongoDB.Driver/VectorQuantization.cs Defines enum for vector quantization types (None, Scalar, Binary)
src/MongoDB.Driver/CreateSearchIndexModelBase.cs Introduces abstract base class for search index models
src/MongoDB.Driver/CreateSearchIndexModel.cs Refactors to inherit from base class and updates documentation
src/MongoDB.Driver/CreateVectorIndexModel.cs Implements typed vector index model with field expressions and rendering logic
src/MongoDB.Driver/Search/IMongoSearchIndexManager.cs Updates interface to accept base class type
src/MongoDB.Driver/MongoCollectionImpl.cs Updates implementation to handle both search and vector index models
tests/MongoDB.Driver.Tests/Search/AtlasSearchIndexManagmentTests.cs Adds comprehensive tests for typed vector index API and updates existing tests
evergreen/evergreen.yml Updates MongoDB version from 7.0 to 8.0 for search index tests

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ajcvickers
Copy link
Contributor Author

@rstam This is a new implementation which, I think, does the rendering properly.

@ajcvickers ajcvickers requested a review from rstam October 20, 2025 12:12
Copy link
Contributor

@rstam rstam left a comment

Choose a reason for hiding this comment

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

Two minor questions/suggestions.

/// <summary>
/// Defines a vector index model using strongly-typed C# APIs.
/// </summary>
public sealed class CreateVectorIndexModel<TDocument> : CreateSearchIndexModel
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but should this class be named CreateVectorSearchIndexModel?

The server calls this type of index a "vector search index"?

}
}

return new BsonDocument { { "fields", BsonArray.Create(fieldDocuments) } };
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use new BsonArray(fieldDocuments) instead of BsonArray.Create(fieldDocuments).

BsonArray.Create takes a single object parameter and does all sorts of weird obsolete mappings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants