ResultSet
A ResultSet instance is a search or query result set returned by Search(), HybridSearch(), Query(), and Get(). It holds the returned entry count, primary keys, output fields, and scores.
type ResultSet struct {
ResultCount int
GroupByValue column.Column
IDs column.Column
Fields DataSet
AggregationBuckets []AggregationBucket
Scores []float32
Recall float32
Err error
}
FIELDS:
-
ResultCount (int) -
The number of returned entries.
-
GroupByValue (column.Column) -
The group-by column value when the search/query used grouping.
-
IDs (column.Column) -
The primary-key column of the matched entities.
-
Fields (DataSet) -
The output field columns.
-
AggregationBuckets ([]AggregationBucket) -
Search aggregation results for this query, when an aggregation was requested.
-
Scores ([]float32) -
The distance to the target vector for each match.
-
Recall (float32) -
The estimated recall of the search result (estimated by Zilliz Cloud).
-
Err (error) -
The search error, if any.
BUILDER METHODS:
-
GetColumn(fieldName string) column.ColumnReturns the column with the provided field name.
-
Len() intReturns the number of returned entries.
-
Slice(start, end int) ResultSetReturns a sub-set of the result between the given start and end indexes.
-
Unmarshal(receiver any) errorUnmarshals the data set into a slice of pointers to model structs in a row-based way. Note that distance/score is not unmarshaled here.
Example
Demonstrates ResultSet usage.
import (
"context"
"github.com/milvus-io/milvus/client/v3/milvusclient"
)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cli, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "YOUR_CLUSTER_ENDPOINT",
})
if err != nil {
// handle error
}
defer cli.Close(ctx)
resultSets, err := cli.Search(ctx, milvusclient.NewSearchOption("books", 10, vectors))
if err != nil {
// handle error
}
resultSet := resultSets[0]
fmt.Println(resultSet.ResultCount, resultSet.Scores)