cloudwego / cloudwego/eino-ext

Milvus2 retriever 范围搜索参数序列化错误

Open
#893 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
811
Forks
368
Avg merge
16h 22m
Merged PRs (30d)
13

Description

**Describe the bug**

具体描述
Milvus中只有4条向量,对应的score是:
- 0.4326685
- 0.40756223
- 0.16714698
- 0.14266507
TopK设置了100,当使用 `search_mode.NewRange(milvus2.COSINE, 0.4)` 的时候,发现返回了4条记录。当使用Milvus官方SDK时,返回了2条记录。返回数据结果有误。
即使更改`radius`和使用`*search_mode.Range.WithRangeFilter()`设置,结果仍然是返回了4条记录。

**To Reproduce**

Eino demo:https://github.com/cloudwego/eino-ext/blob/main/components/retriever/milvus2/examples/range/range.go的例子,embedder为openai的text-embedding-3-small
Milvus demo:https://milvus.io/docs/zh/v2.6.x/range-search.md 稍作修改
```go
annParam := index.NewCustomAnnParam()
annParam.WithRadius(0.4)
annParam.WithRangeFilter(1.0)

res, err := client.Search(
ctx,
milvusclient.NewSearchOption(
"test",
5,
[]entity.Vector{
entity.FloatVector(ToFloat32Slice(query)),
},
).
WithANNSField("vector").
WithConsistencyLevel(entity.ClStrong).
WithAnnParam(annParam),
)
```

**Expected behavior**

应该返回 `0.4326685` 、`0.40756223`这两条记录才对。

**Version:**
- eino-ext/components/retriever/milvus2 version : v0.1.0
- Milvus version: v2.6.13
- Metric Type: COSINE

**Environment:**
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=1
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=on
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\sakana\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\sakana\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\sakana\AppData\Local\Temp\go-build1075550778=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=G:\项目\go\eino\go.mod
set GOMODCACHE=F:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=F:\gopath
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=F:\go1.25.3
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\sakana\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=F:\go1.25.3\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.25.3
set GOWORK=
set PKG_CONFIG=pkg-config

**Additional context**

docker log
对于Eino Milvus2的查询
[2026/06/20 09:08:06.246 +00:00] [ACCESS] Search [status: Successful] [code: 0] [sdk: GoMilvusClient-2.6.1] [msg: ] [traceID: fc3090e9c4354a6b5107564cf9ca6372] [timeCost: 27.322005ms] [database: AwesomeEino] [collection: test] [partitions: []] [expr: ] [nq: 1] [params: {"anns_field":"vector","ignore_growing":"false","metric_type":"COSINE","offset":"0","params":"{}","radius":"0.4","range_filter":"1","round_decimal":"-1","topk":"100"}]

对于Milvus SDK的查询
[2026/06/20 07:49:36.142 +00:00] [ACCESS] Search [status: Successful] [code: 0] [sdk: GoMilvusClient-2.6.1] [msg: ] [traceID: aa2086d6f245fe4a3670c9e072006559] [timeCost: 28.577651ms] [database: AwesomeEino] [collection: test] [partitions: []] [expr: ] [nq: 1] [params: {"anns_field":"vector","ignore_growing":"false","metric_type":"","offset":"0","params":"{\"radius\":0.4,\"range_filter\":1}","round_decimal":"-1","topk":"5"}]

官方例子:
```shell
export CLUSTER_ENDPOINT="http://localhost:19530"
export TOKEN="root:Milvus"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/search" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
--header "Request-Timeout: 10" \
-d '{
"collectionName": "my_collection",
"data": [
[0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, 0.9029438446296592]
],
"annsField": "vector",
"limit": 5,
"searchParams": {
"params": {
"radius": 0.4,
"range_filter": 0.6
}
}
}'
```
可以发现radius,range_filter 请求的参数不在params里面。

Contributor guide

Open the contributing guide

Research direction

Start with components/retriever/milvus2/examples/range/range.go and reproduce the range search using the reported Milvus and Eino versions. Compare the emitted request parameters with the official SDK example, focusing on where radius and range_filter are serialized. Done means the request uses the expected parameter structure and the example returns only the two records above the 0.4 threshold.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.