diff --git a/tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs index 049318b4425..92ee410ee48 100644 --- a/tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs +++ b/tests/MongoDB.Driver.Tests/Search/AtlasSearchTests.cs @@ -63,6 +63,9 @@ public AtlasSearchTests(ITestOutputHelper testOutputHelper) : base(testOutputHel var atlasSearchUri = Environment.GetEnvironmentVariable("ATLAS_SEARCH"); Ensure.IsNotNullOrEmpty(atlasSearchUri, nameof(atlasSearchUri)); + var mongoClientSettings = MongoClientSettings.FromConnectionString(atlasSearchUri); + mongoClientSettings.ClusterSource = DisposingClusterSource.Instance; + _mongoClient = new MongoClient(atlasSearchUri); } diff --git a/tests/MongoDB.Driver.Tests/Search/VectorSearchTests.cs b/tests/MongoDB.Driver.Tests/Search/VectorSearchTests.cs index d55a0c24b13..0e77039bd82 100644 --- a/tests/MongoDB.Driver.Tests/Search/VectorSearchTests.cs +++ b/tests/MongoDB.Driver.Tests/Search/VectorSearchTests.cs @@ -39,22 +39,29 @@ public VectorSearchTests(ITestOutputHelper testOutputHelper) : base(testOutputHe var atlasSearchUri = Environment.GetEnvironmentVariable("ATLAS_SEARCH"); Ensure.IsNotNullOrEmpty(atlasSearchUri, nameof(atlasSearchUri)); + var mongoClientSettings = MongoClientSettings.FromConnectionString(atlasSearchUri); + mongoClientSettings.ClusterSource = DisposingClusterSource.Instance; + _mongoClient = new MongoClient(atlasSearchUri); } protected override void DisposeInternal() => _mongoClient.Dispose(); - [Theory(Skip = "Shared BsonVector cluster not set. TODO BEFORE MERGE")] + [Theory] [MemberData(nameof(BsonVectorSearchTestData))] public void BsonVectorSearch(BsonVectorBase bsonVector, string fieldName) where T : struct { const int Limit = 5; - var collection = _mongoClient.GetDatabase("vectorSearch").GetCollection("BinaryVectorTests"); + var collection = _mongoClient.GetDatabase("csharpExtraTests").GetCollection("binaryVectorTests"); var options = new VectorSearchOptions() { IndexName = "vector_search_index" }; - var result = collection.Aggregate().VectorSearch(fieldName, bsonVector.ToQueryVector(), Limit).ToList(); + var result = collection + .Aggregate() + .VectorSearch(fieldName, bsonVector.ToQueryVector(), Limit, options) + .Project(Builders.Projection.MetaVectorSearchScore(p => p.Score)) + .ToList(); result.Count.Should().Be(Limit); result.Should().BeInDescendingOrder(b => b.Score);