Skip to content

Implement MilvusClientV2 (2.6) - #141

Open
yhmo wants to merge 1 commit into
milvus-io:mainfrom
yhmo:ma
Open

Implement MilvusClientV2 (2.6)#141
yhmo wants to merge 1 commit into
milvus-io:mainfrom
yhmo:ma

Conversation

@yhmo

@yhmo yhmo commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

issue: #139

Summary

Adds MilvusClientV2, a new DTO-based Milvus client targeting the 2.6 API surface, alongside the existing V1 Milvus.Client. The client mirrors the V2 SDKs (Java / C++ / PyMilvus) with per-operation request/response DTOs, internal generated gRPC types, and the shared cache/retry infrastructure described in the design doc.

The milvus-proto submodule is upgraded to the 2.6 branch (a76db65) and relocated to the repository root, since it is now a shared build-time dependency of both the V1 and V2 assemblies. Neither published package references the protos at runtime.

What's included

Complete 2.6 API surface (Milvus.Client.V2)

  • Collection & schema: create/drop/describe/alter, field & function operations, properties, replicas, truncate, refresh-load
  • Index: create/drop/describe/list, index properties
  • DML: insert / upsert / delete with Session-consistency timestamp tracking
  • DQL: get / query / search / hybrid search (RRF & weighted rerankers) / query & search iterators
  • Partition / database / alias
  • RBAC: users, roles, privileges, v2 privilege model, privilege groups
  • Resource group, utility (flush, compact, analyze, CDC / replicate info), bulk import

Mechanisms

  • CollectionTsCache (Session read-your-writes) and single-flight SchemaCache, keyed by endpoint/database/collection
  • RetryPolicy with the two-layer retryable-error decision (gRPC blacklist + server RateLimit), aligned with PyMilvus/Java/C++
  • Server-streaming DumpMessages and lazy paged iterators

Quality & docs

  • Three-layer test suite (Unit / Integration with in-process mock server / System against a real container)
  • Runnable per-feature examples with doc headers and Snippet annotations
  • BFloat16 vector support, nullable/JSON FieldData fixes, DropCollection cache invalidation

Compatibility

  • V1 Milvus.Client is unchanged in behavior and remains buildable after the proto upgrade
  • Both NuGet packages are unaffected by the submodule relocation (protos are a build-time-only input)

Test plan

dotnet test Milvus.Client.sln
  • V2: 80/80 passing
  • V1: 240 passing, 1 skipped

@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@yhmo Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify

mergify Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It introduces a large new client surface area plus core caching/endpoint normalization and request-shaping logic where multiple concrete correctness issues were found that should be addressed and re-validated.

Pull request overview

This PR introduces a new Milvus.Client.V2 SDK implementation targeting the Milvus 2.6 API surface (DTO-based request/response pattern with a single MilvusClientV2 facade), while keeping the existing V1 client buildable after relocating/upgrading the shared milvus-proto submodule.

Changes:

  • Adds the new Milvus.Client.V2 library (DTO requests/responses, types, utilities like timestamp/schema caches and retry infrastructure).
  • Adds a V2-focused test suite (unit/integration/system) and runnable examples showcasing V2 features.
  • Relocates the milvus-proto submodule to the repo root and updates solution/package wiring to include V2 projects.
File summaries
File Description
Milvus.Client/Milvus.Client.csproj Updates protobuf include paths to reference protos from the new repo-root Protos location.
.gitmodules Relocates the milvus-proto submodule entry to the repo root (Protos).
Directory.Packages.props Adds centralized package versions needed for the new V2 test infrastructure.
Milvus.Client.sln Adds the V2 library and V2 test projects to the solution.
Milvus.Client.V2/Utils/Verify.cs Adds V2 argument validation helpers used across DTOs.
Milvus.Client.V2/Utils/TypeMappings.cs Adds enum-to-wire-string mapping for index/search request parameters.
Milvus.Client.V2/Utils/MilvusTimestampUtils.cs Adds timestamp conversion helpers for guarantee/time-travel timestamps.
Milvus.Client.V2/Utils/Logging.cs Adds source-generated logging extension methods for V2 client operations.
Milvus.Client.V2/Utils/CompilerAttributes.cs Adds internal compatibility attributes for older target frameworks.
Milvus.Client.V2/Utils/CollectionCacheKey.cs Adds cache key normalization for schema/TS caches keyed by endpoint/db/collection.
Milvus.Client.V2/Types/* Introduces public V2 types/enums supporting the 2.6 API surface (metrics, load/index states, iterators, retry config, replication models, etc.).
Milvus.Client.V2/Requests/* Adds DTO request objects for V2 operations (collection/index/DML/DQL/utility/RBAC/etc.).
Milvus.Client.V2/Responses/* Adds DTO response objects for V2 operations.
Milvus.Client.V2/MilvusException.cs Adds V2 exception type carrying MilvusErrorCode.
Milvus.Client.V2/MilvusErrorCode.cs Adds V2 error code enum.
Milvus.Client.V2/MilvusClientV2.BulkImport.cs Adds Bulk Import facade methods wired to DTOs and gRPC calls.
Milvus.Client.V2.Tests/Milvus.Client.V2.Tests.csproj Adds the V2 test project and its dependencies.
Milvus.Client.V2.Tests/Unit/* Adds unit tests for V2 utilities and request mapping logic.
Milvus.Client.V2.Tests/Integration/* Adds integration tests using an in-process mock server to validate client behavior.
Milvus.Client.V2.Tests/System/* Adds system tests against a real Milvus container.
examples/Milvus.Examples.csproj Adds runnable examples project referencing Milvus.Client.V2.
examples/Program.cs Adds an example runner/dispatcher for V2 examples.
examples/*Example.cs Adds runnable V2 examples demonstrating specific features (RBAC, analyzer, aliases, nullable fields, etc.).
examples/ExampleHelpers.cs Adds shared helper utilities for making examples idempotent and easy to run.
Review details
  • Files reviewed: 271/272 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Milvus.Client.V2/Request/Dql/GetReq.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.cs Outdated
Comment thread Milvus.Client.V2/MilvusException.cs
Comment thread Milvus.Client.V2/Request/Index/GetIndexStateReq.cs Outdated
Comment thread Milvus.Client.V2/Utils/CollectionCacheKey.cs Outdated
Comment thread Milvus.Client.V2/Utils/MilvusTimestampUtils.cs Outdated
Comment thread Milvus.Client.V2/Types/SimilarityMetricType.cs
Comment thread Milvus.Client.V2/Utils/Verify.cs
Comment thread Milvus.Client.V2/Request/Dml/InsertReq.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.Rbac.cs Outdated
Comment thread Milvus.Client.V2/Types/FieldData.cs
Comment thread Milvus.Client.V2/MilvusClientV2.Dql.cs
Comment thread Milvus.Client.V2/MilvusClientV2.Utility.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.ResourceGroup.cs Outdated
Comment thread Milvus.Client.V2/Utils/RetryPolicy.cs Outdated
Comment thread Milvus.Client.V2/Utils/RetryPolicy.cs
Comment thread Milvus.Client.V2/Request/Dql/SearchReq.cs Outdated
Comment thread Milvus.Client.V2/Request/Collection/AddCollectionFieldReq.cs Outdated
Comment thread Milvus.Client.V2/Response/Utility/PersistentSegmentInfo.cs Outdated
Comment thread Milvus.Client.V2/Response/Utility/GetServerVersionResp.cs
Comment thread Milvus.Client.V2/Utils/DqlConversions.cs
Comment thread Milvus.Client.V2/Response/Collection/DescribeCollectionResp.cs
@mergify

mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@yhmo Thanks for your contribution. Please submit with DCO, see the contributing guide https://github.com/milvus-io/milvus/blob/master/CONTRIBUTING.md#developer-certificate-of-origin-dco.

@mergify mergify Bot added needs-dco and removed dco-passed labels Sep 4, 2026
@yhmo
yhmo force-pushed the ma branch 2 times, most recently from a14a449 to 909287b Compare September 4, 2026 07:42
Comment thread Milvus.Client.V2/MilvusClientV2.Collection.cs Outdated
Comment thread Milvus.Client.V2/Request/Dql/SearchReq.cs Outdated
@yhmo
yhmo force-pushed the ma branch 3 times, most recently from 99e4dc8 to 8ace961 Compare September 14, 2026 04:22
Comment thread Milvus.Client.V2/Request/Index/DescribeIndexReq.cs Outdated
Comment thread Milvus.Client.V2/Utils/CollectionCacheKey.cs Outdated
Comment thread Milvus.Client.V2/Response/Utility/FlushAllResp.cs
Comment thread Milvus.Client.V2/MilvusClientV2.Dql.cs
Comment thread Milvus.Client.V2/Utils/RetryPolicy.cs
Comment thread Milvus.Client.V2/Utils/DqlConversions.cs
@yhmo
yhmo force-pushed the ma branch 3 times, most recently from 202430c to 97feaf7 Compare September 14, 2026 08:08
Comment thread Milvus.Client.V2/MilvusClientV2.Rbac.cs
Comment thread Milvus.Client.V2/Request/Rbac/GrantPrivilegeReqV2.cs
Comment thread Milvus.Client.V2/Response/Utility/DumpMessagesResp.cs
Comment thread Milvus.Client.V2/MilvusClientV2.Utility.cs
Comment thread Milvus.Client.V2/Request/Utility/GetFlushStateReq.cs Outdated
Comment thread Milvus.Client.V2.Tests/Integration/UtilityBulkImportApiTests.cs Outdated
Comment thread Milvus.Client.V2/Types/ArrayFieldData.cs
Comment thread Milvus.Client.V2/BulkImport.cs Outdated
Comment thread Milvus.Client.V2/BulkImport.cs Outdated
Comment thread Milvus.Client.V2/MilvusClientV2.Alias.cs
Comment thread Milvus.Client.V2/Utils/MilvusTimestampUtils.cs Outdated
Comment thread Milvus.Client.V2/Request/Utility/FlushReq.cs Outdated
Comment thread Milvus.Client.V2/Request/Utility/RunAnalyzerReq.cs
Comment thread Milvus.Client.V2/Request/Utility/GetMetricsReq.cs Outdated
## Summary

Adds **MilvusClientV2**, a new DTO-based Milvus client targeting the **2.6 API surface**, alongside the existing V1 `Milvus.Client`. The client mirrors the V2 SDKs (Java / C++ / PyMilvus) with per-operation request/response DTOs, internal generated gRPC types, and the shared cache/retry infrastructure described in the design doc.

The `milvus-proto` submodule is upgraded to the 2.6 branch (`a76db65`) and relocated to the repository root, since it is now a shared build-time dependency of both the V1 and V2 assemblies. Neither published package references the protos at runtime.

## What's included

**Complete 2.6 API surface** (`Milvus.Client.V2`)
- Collection & schema: create/drop/describe/alter, field & function operations, properties, replicas, truncate, refresh-load
- Index: create/drop/describe/list, index properties
- DML: insert / upsert / delete with Session-consistency timestamp tracking
- DQL: get / query / search / **hybrid search** (RRF & weighted rerankers) / **query & search iterators**
- Partition / database / alias
- RBAC: users, roles, privileges, v2 privilege model, privilege groups
- Resource group, utility (flush, compact, analyze, CDC / replicate info), bulk import

**Mechanisms**

Signed-off-by: yhmo <yihua.mo@zilliz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants