From 5a960e98f3667a6827dc6f3191b1ee78814f4257 Mon Sep 17 00:00:00 2001 From: Gao Date: Wed, 18 Dec 2024 16:26:39 +0800 Subject: [PATCH] enhance: support recall in SearchResult (#862) #861 Signed-off-by: chasingegg --- client/data.go | 4 ++++ client/results.go | 1 + go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/data.go b/client/data.go index bee6da15..17b82038 100644 --- a/client/data.go +++ b/client/data.go @@ -141,6 +141,10 @@ func (c *GrpcClient) handleSearchResult(schema *entity.Schema, outputFields []st Scores: results.GetScores()[offset : offset+rc], } + if len(results.GetRecalls()) > 0 { + entry.Recall = results.GetRecalls()[i] + } + entry.IDs, entry.Err = entity.IDColumns(schema, results.GetIds(), offset, offset+rc) if entry.Err != nil { continue diff --git a/client/results.go b/client/results.go index 8aba95ac..bbca832c 100644 --- a/client/results.go +++ b/client/results.go @@ -21,6 +21,7 @@ type SearchResult struct { IDs entity.Column // auto generated id, can be mapped to the columns from `Insert` API Fields ResultSet //[]entity.Column // output field data Scores []float32 // distance to the target vector + Recall float32 // recall of the query vector's search result (estimated by zilliz cloud) Err error // search error if any } diff --git a/go.mod b/go.mod index 682c5f09..1fd838ab 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-faker/faker/v4 v4.1.0 github.com/golang/protobuf v1.5.2 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 - github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20241120015424-93892e628c69 + github.com/milvus-io/milvus-proto/go-api/v2 v2.5.0-beta.0.20241125085227-a6cba3e091b5 github.com/stretchr/testify v1.8.1 github.com/tidwall/gjson v1.14.4 github.com/x448/float16 v0.8.4 diff --git a/go.sum b/go.sum index 5b224a25..64969703 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20241120015424-93892e628c69 h1:Qt0Bv2Fum3EX3OlkuQYHJINBzeU4oEuHy2lXSfB/gZw= -github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20241120015424-93892e628c69/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs= +github.com/milvus-io/milvus-proto/go-api/v2 v2.5.0-beta.0.20241125085227-a6cba3e091b5 h1:E0FAEtCM3/XX/nesgEDEdkXB3GOSCLWKnOv7PipaRzU= +github.com/milvus-io/milvus-proto/go-api/v2 v2.5.0-beta.0.20241125085227-a6cba3e091b5/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=