Files
milvus/client
f244642ba9 enhance: support query order-by in RESTful v2 API and Go SDK (#51170) (#51173)
issue: #51170

Expose the existing server-side query ORDER BY capability (query param
key `order_by_fields`, already consumed by proxy `task_query.go`)
through the two remaining client surfaces:

- **Go SDK**: `queryOption.WithOrderByFields(fields ...string)` — each
spec is `"field"`, `"field:asc"` or `"field:desc"`, joined into the
`order_by_fields` query param.
- **RESTful v2**: `QueryReqV2` gains `orderByFields` (`[]string`, same
spec format), forwarded by the query handler as the `order_by_fields`
query param.

Validation (sortable type, explicit-limit requirement, iterator
exclusion) stays server-side in the proxy, consistent with how
limit/offset/group-by are handled at these layers. Interface shape
mirrors pymilvus (`order_by=["price:desc"]`).

Tests: Go SDK option unit test, RESTful v2 handler unit test (asserts
the KV pair is forwarded, and absent when not requested), and a
go_client e2e case (desc / asc-default / no-limit rejection).

Follow-up (out of scope here): search-side `order_by` first-class parity
for RESTful v2 / Go SDK (currently reachable via raw search params
only).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: MrPresent-Han <chun.han@gmail.com>
Co-authored-by: MrPresent-Han <chun.han@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 18:28:35 +08:00
..
2026-07-07 13:38:30 +08:00
2026-07-07 13:38:30 +08:00

Go MilvusClient

license Go Reference

Go MilvusClient for Milvus. To contribute code to this project, please read our contribution guidelines first.

Getting started

Prerequisites

Go 1.24.12 or higher

Install Milvus Go SDK

  1. Use go get to install the latest version of the Milvus Go SDK and dependencies:

    go get -u github.com/milvus-io/milvus/client/v2
    
  2. Include the Go MilvusClient in your application:

     import "github.com/milvus-io/milvus/client/v2/milvusclient"
    
     //...other snippet ...
     ctx, cancel := context.WithCancel(context.Background())
     defer cancel()
    
     milvusAddr := "YOUR_MILVUS_ENDPOINT"
    
     cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
     	Address: milvusAddr,
     })
     if err != nil {
     	// handle error
     }
    
     // Do your work with milvus client
    

API Documentation

Refer to https://milvus.io/api-reference/go/v2.5.x/About.md for the Go SDK API documentation.

Code format

The Go source code is formatted using gci & gofumpt. Please run make lint-fix before sumbit a PR.