mongo-csharp-driver / Search
AGENTS.md3.2k starsChanged 4 months agoApache-2.0View on GitHub
Builders for the $search and $vectorSearch aggregation stages. Atlas-only — there is no local MongoDB equivalent. All tests gated by ATLAS_SEARCH_TESTS_ENABLED and ATLAS_SEARCH_URI. Two builder hubs reachable from Builders<TDocument>: SearchScoreFunction name collision. The name is shared by two unrelated types. Builders<T>.SearchScoreFunction (a property) returns a SearchScoreFunctionBuilder<TDocument>, which produces the generic SearchScoreFunction<TDocument> expression class for Function(...) score modifiers. Separately, at the driver root, SearchScoreFunction is also a plain enum (src/MongoDB.Driver/SearchScoreFunction.cs) used by VectorSearchOptions.EmbeddedScoreMode. They share a name but aren't overloads. Don't…
Trending
Quiet since September.about the whole repository
Who's talking about mongodb/mongo-csharp-driver
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Support for latest MongoDB library with signing”GitHub · Jul 28, 2024 · 13 reactions
- opensearch-project/opensearch-net“[FEATURE] Add LINQ Support to the OpenSearch C# Client”GitHub · Sep 18, 2023 · 5 reactions
- nopSolutions/nopCommerce“MongoDB database support”GitHub · Apr 30, 2019 · 4 reactions
- microsoft/aspire“MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration”GitHub · Oct 18, 2024 · 3 reactions
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Deprecate this package”GitHub · Apr 21, 2026 · 2 reactions
The biggest 5 of 40 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 40
Talked about on GitHub (40 times).
On GitHub · 40
- Jul 28, 2024Support for latest MongoDB library with signing — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources13 reactions · 5 comments
- Sep 18, 2023[FEATURE] Add LINQ Support to the OpenSearch C# Client — opensearch-project/opensearch-net5 reactions · 1 comment
- Apr 30, 2019MongoDB database support — nopSolutions/nopCommerce4 reactions · 24 comments
- Oct 18, 2024MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration — microsoft/aspire3 reactions · 9 comments
- Apr 21, 2026Deprecate this package — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources2 reactions · 1 comment
35 more on GitHub
- Nov 5, 2025Corrected Membership Session Handling — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 2 comments
- Jun 4, 2016Support .NET Core — tugberkugurlu/AspNetCore.Identity.MongoDB2 reactions · 1 comment
- Jul 12, 2026Upgrade MongoDB.Driver to 3.9.0 to fix Snappier and SharpCompress vulnerabilities — madelson/DistributedLock1 reaction
- May 28, 2026Upgrade MongoDB.Driver to 3.9.0 — abpframework/abp1 reaction · 1 comment
- May 12, 2026Upgrade MongoDB.Driver to 3.8.1 — abpframework/abp1 reaction
- Mar 19, 2026bump MongoDB.Driver to 3.7.1 — abpframework/abp1 reaction
- Jan 18, 2026Update MongoDB.Driver package version to 3.6.0 — abpframework/abp1 reaction · 1 comment
- Nov 20, 2025Update MongoDB.Driver to version 3.5.1 — abpframework/abp1 reaction
- Jan 30, 2023Hangfire.Mongo is incompatible with the MongoDB.Driver LINQ3 provider — gottscj/Hangfire.Mongo1 reaction · 1 comment
- Jun 6, 2022Mongo Driver Compatibility — alirezanet/Gridify1 reaction · 3 comments
- Mar 31, 2015Support for 2.0 async driver — RobThree/MongoRepository1 reaction · 35 comments
- Sep 29, 2026Bump MongoDB.Driver from 2.11.5 to 2.19.0 — ramonaoldf/run-devops0 reactions
- Sep 15, 2026Bump the nuget group with 1 update — ApurvSinghal/ApurvXam0 reactions
- Aug 2, 2026Bump MongoDB.Driver from 2.8.1 to 2.19.0 — mohaom/TailwindTraders-Website0 reactions
- Jan 12, 2025Bump MongoDB.Driver from 2.14.1 to 2.19.0 in /src/Infrastructure — vigovlugt/LeagueOfItemsBackend0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.19.0 [SECURITY] — MrDariusAD/DynamicFilter0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — ShamKarthikS-Hexaware/recicd0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — MrDariusAD/GirlfriendAdventskalender0 reactions
- Jan 15, 2024Bump MongoDB.Driver.Core and MongoDB.Bson — kravvya/GardenLog.V20230 reactions
- Nov 17, 2023build(deps): bump MongoDb_Version from 2.19.0 to 2.22.0 — AntonioFalcaoJr/EventualShop0 reactions
- Mar 28, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — eincioch/dotnet-microservices-boilerplate0 reactions
- Mar 27, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — niaz-ali-khan/microservise0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.13.1 to 2.19.0 in /DotNet/POC/DatabaseBenchmark — AdamNagy/Nadam.Tryouts0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.12.3 to 2.19.0 in /Esiur.Stores.MongoDB — esiur/esiur-dotnet0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.17.1 to 2.18.0 in /src/backend — ScottishTapWater/OrderBook0 reactions
- Oct 17, 2022fix(deps): bump MongoDB.Driver from 2.16.1 to 2.18.0 — Manu0912/doppler-push-contact0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.13.0 to 2.18.0 — uruk-project/uruk-server0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.15.1 to 2.18.0 — joelbyford/ApiPatternsClient0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.13.1 to 2.18.0 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/common/Platform.Common — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/lobby/Platform.Lobby.Tests — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/eucre-game/Games.Eucre.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/weather/Weather.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/library/Platform.Library.Api — frogsbreath-games/eucre0 reactions
- May 24, 2022Bump MongoDB.Driver from 2.13.1 to 2.15.1 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/MongoDB.Bson/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Authentication/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Authentication.AWS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Bindings/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Events/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Logging/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Operations/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/GeoJsonObjectModel/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/GridFS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Linq/AGENTS.mdAGENTS.md
- tests/MongoDB.Driver.TestHelpers/AGENTS.mdAGENTS.md
- tests/MongoDB.Driver.Tests/Specifications/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- src/MongoDB.Bson/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Authentication.AWS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Authentication/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Bindings/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Events/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Logging/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Operations/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GeoJsonObjectModel/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GridFS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Linq/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Search/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.TestHelpers/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.Tests/Specifications/CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 58
Atlas-only: Don't ship search-using code paths to environments that may run on local MongoDB without an Atlas backend.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Atlas Search & Vector Search — AGENTS.md
Builders for the $search and $vectorSearch aggregation stages. Atlas-only — there is no local MongoDB equivalent. All tests gated by ATLAS_SEARCH_TESTS_ENABLED and ATLAS_SEARCH_URI.
Public API
Two builder hubs reachable from Builders<TDocument>:
Builders<T>.Search—SearchDefinition<TDocument>builders for$search.Builders<T>.SearchPath,Builders<T>.SearchScore,Builders<T>.SearchScoreFunction,Builders<T>.SearchFacet,Builders<T>.SearchSpan— supporting builder hubs for path / scoring / score-function expressions / faceting / span queries.
SearchScoreFunction name collision. The name is shared by two unrelated types. Builders<T>.SearchScoreFunction (a property) returns a SearchScoreFunctionBuilder<TDocument>, which produces the generic SearchScoreFunction<TDocument> expression class for Function(...) score modifiers. Separately, at the driver root, SearchScoreFunction is also a plain enum (src/MongoDB.Driver/SearchScoreFunction.cs) used by VectorSearchOptions.EmbeddedScoreMode. They share a name but aren't overloads. Don't wire the enum into a Function(...) call.
Index helpers live at the root of src/MongoDB.Driver/: the non-generic CreateSearchIndexModel, plus the generic CreateVectorSearchIndexModel<TDocument> and CreateAutoEmbeddingVectorSearchIndexModel<TDocument> (both inheriting CreateVectorSearchIndexModelBase<TDocument>), and SearchIndexType. Index management goes through IMongoCollection<T>.SearchIndexes.
Operators
SearchDefinitionBuilder<T> covers leaf operators returning SearchDefinition<T>: Autocomplete, EmbeddedDocument, Equals, Exists, Facet, GeoShape, GeoWithin, HasAncestor, HasRoot, In, MoreLikeThis, Near, Phrase, QueryString, Range, Regex, Span, Text, Wildcard, VectorSearch. Compound is a builder hub rather than a leaf — Builders<T>.Search.Compound() returns a CompoundSearchDefinitionBuilder<TDocument> for assembling must / mustNot / should / filter clauses with minimumShouldMatch.
Vector search
Two paths:
- Top-level stage:
IAggregateFluent<T>.VectorSearch(path, queryVector, limit, options)— preferred for pure vector queries. - Inside compound:
Builders<T>.Search.VectorSearch(...)— for hybrid (text + vector) queries.
Key types:
QueryVector— note this type lives at the driver root (src/MongoDB.Driver/QueryVector.cs), not underSearch/. Two ways in:- Implicit conversions (common case): from
double[]/float[]/int[]for raw numeric arrays, fromReadOnlyMemory<double|float|int>for memory shapes, fromBinaryVectorInt8/BinaryVectorFloat32/BinaryVectorPackedBitfor the typed BinaryVector encodings, or fromstringfor Atlas auto-embedding. The array forms route through aprivate QueryVector(BsonArray)ctor — there is nopublic QueryVector(double[])overload, sonew QueryVector(myDoubleArray)does not compile; use the implicit conversion (or pass the array in to a method that acceptsQueryVector). - Explicit constructors are limited to:
string(auto-embedding),BsonBinaryData(the one input shape with no implicit conversion — must be called explicitly), and the threeReadOnlyMemory<double|float|int>overloads.
See
src/MongoDB.Driver/QueryVector.csfor the authoritative constructor list.- Implicit conversions (common case): from
VectorSearchOptions<TDocument>— for the top-levelIAggregateFluent<T>.VectorSearchstage. CarriesFilter(aFilterDefinition<TDocument>pre-filter),NestedFilter,NumberOfCandidates(search-set size for ANN),Exact(true → ENN, ignores candidates), plus auto-embedding-related fieldsIndexName,AutoEmbeddingModelName,ReturnStoredSource, andEmbeddedScoreMode. The compound-embedded form (Builders<T>.Search.VectorSearch) takes the related but distinctVectorSearchOperatorOptions<TDocument>— don't conflate them.VectorSearchOperatorOptions<TDocument>has a deliberately smaller surface (it omits the auto-embedding fields andEmbeddedScoreModethat only make sense at the top-level stage); reach for it only inside a compound query.
Tuning rule: for approximate (ANN) searches NumberOfCandidates should be much larger than Limit — typical ratio 10×–20×. Exact = true switches to exact nearest-neighbor and ignores NumberOfCandidates.
Score modifiers, highlighting, faceting
SearchScoreDefinition<T>/ builders forBoost,Constant,Function(with custom expressions). Apply viascore: …on most operators.SearchHighlight,SearchHighlightOptionsfor hit highlighting in returned documents.SearchMetaResult(non-generic) carries facet counts (returned as the result of$searchMeta).SearchSpanDefinition<TDocument>(built viaBuilders<T>.SearchSpan) describes span queries — sequence/proximity/order constraints over the text positions of subordinate clauses.Builders<T>.SearchFacetbuilds string / numeric / date facets to embed in the search stage.
Common pitfalls
$searchmust be the first stage in the pipeline.$vectorSearchlikewise. The driver doesn't enforce this — Atlas does, with an error that's easy to misread. If you have predicates that should run before, fold them into the search stage'scompound.filter(free, indexed) rather than a downstream$match(server-side, after scoring).- Index naming. The
indexparameter on$search/$vectorSearchrefers to an Atlas Search index by name, not a MongoDB collection name. Wrong index → empty results, no error. NumberOfCandidates<Limit. Approximate search degrades silently to lower-quality results. The driver doesn't validate the relationship.- Atlas-only. Don't ship search-using code paths to environments that may run on local MongoDB without an Atlas backend. Tests gated by
ATLAS_SEARCH_TESTS_ENABLEDexist to keep local CI runs green. UseConfiguredSerializerson value-comparing operators. Default is true (registered serializers are honored, e.g. enum-as-string). The extension isSearchDefinitionExtensions.UseConfiguredSerializers— declared onSearchDefinition<TDocument>but downcasts toOperatorSearchDefinition<TDocument>and throwsNotSupportedExceptionif the receiver isn't one. Only three operators actually read the flag —Equals,In, andRange(see the threeif (_useConfiguredSerializers)checks inOperatorSearchDefinitions.cs); on any otherOperatorSearchDefinition<TDocument>the flag is stored but never consulted, so the call is silently a no-op. Setting it tofalsemakes those three operators compare against raw BSON, ignoring custom serializers — the breaking case is flipping it off and silently changing the search semantics.- Compound clause precedence.
mustrequires every clause;shouldadds score but does not require;filterrequires without affecting score;mustNotexcludes. Mixing these is the most common source of "why are these documents missing".
How to test
ATLAS_SEARCH_TESTS_ENABLED=true ATLAS_SEARCH_URI=<atlas-uri> \
dotnet test tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj -f net10.0 \
--filter "FullyQualifiedName~Search"Index-helper tests additionally require ATLAS_SEARCH_INDEX_HELPERS_TESTS_ENABLED=true. See the env-var table in the root AGENTS.md.
Where index management is being changed without an Atlas environment available, stop and ask — local MongoDB cannot fake the search index API.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

