Documentation ¶
Overview ¶
Package client provides milvus client functions
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrClientNotReady error indicates client not ready ErrClientNotReady = errors.New("client not ready") //ErrStatusNil error indicates response has nil status ErrStatusNil = errors.New("response status is nil") )
var ( // ErrFieldTypeNotMatch error for field type not match ErrFieldTypeNotMatch = errors.New("field type not matched") )
Functions ¶
Types ¶
type Client ¶
type Client interface { // Close close the remaining connection resources Close() error // ListCollections list collections from connection ListCollections(ctx context.Context) ([]*entity.Collection, error) // CreateCollection create collection using provided schema CreateCollection(ctx context.Context, schema *entity.Schema, shardsNum int32) error // DescribeCollection describe collection meta DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error) // DropCollection drop the specified collection DropCollection(ctx context.Context, collName string) error // GetCollectionStatistics get collection statistics GetCollectionStatistics(ctx context.Context, collName string) (map[string]string, error) // LoadCollection load collection into memory LoadCollection(ctx context.Context, collName string, async bool) error // ReleaseCollection release loaded collection ReleaseCollection(ctx context.Context, collName string) error // HasCollection check whether collection exists HasCollection(ctx context.Context, collName string) (bool, error) // CreatePartition create partition for collection CreatePartition(ctx context.Context, collName string, partitionName string) error // DropPartition drop partition from collection DropPartition(ctx context.Context, collName string, partitionName string) error // ShowParitions list all partitions from collection ShowPartitions(ctx context.Context, collName string) ([]*entity.Partition, error) // HasPartition check whether partition exists in collection HasPartition(ctx context.Context, collName string, partitionName string) (bool, error) // LoadPartitions load partitions into memory LoadPartitions(ctx context.Context, collName string, partitionNames []string, async bool) error // ReleasePartitions release partitions ReleasePartitions(ctx context.Context, collName string, partitionNames []string) error // CreateIndex create index for field of specified collection // currently index naming is not supported, so only one index on vector field is supported CreateIndex(ctx context.Context, collName string, fieldName string, idx entity.Index, async bool) error // DescribeIndex describe index on collection // currently index naming is not supported, so only one index on vector field is supported DescribeIndex(ctx context.Context, collName string, fieldName string) ([]entity.Index, error) // DropINdex drop index from collection with specified field name DropIndex(ctx context.Context, collName string, fieldName string) error // GetIndexState get index state with specified collection and field name // index naming is not supported yet GetIndexState(ctx context.Context, collName string, fieldName string) (entity.IndexState, error) // Insert column-based data into collection, returns id column values Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error) // Flush flush collection, specified Flush(ctx context.Context, collName string, async bool) error // Search search with bool expression Search(ctx context.Context, collName string, partitions []string, expr string, outputFields []string, vectors []entity.Vector, vectorField string, metricType entity.MetricType, topK int, sp entity.SearchParam) ([]SearchResult, error) // CalcDistance calculate the distance between vectors specified by ids or provided CalcDistance(ctx context.Context, collName string, partitions []string, metricType entity.MetricType, opLeft, opRight entity.Column) (entity.Column, error) // -- row basd apis -- // CreateCollectionByRow create collection by row CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error // InsertByRows insert by rows InsertByRows(ctx context.Context, collName string, paritionName string, rows []entity.Row) (entity.Column, error) }
Client is the interface used to communicate with Milvus The common usage is like follow
c, err := client.NewGrpcClient(context.Background, "address-to-milvus") // or other creation func maybe added later if err != nil { //handle err } // start doing things with client instance, note that there is no need to call Connect since NewXXXClient will do that for you
func NewGrpcClient ¶
func NewGrpcClient(ctx context.Context, addr string, dialOptions ...grpc.DialOption) (Client, error)
NewGrpcClient create client with grpc addr the `Connect` API will be called for you dialOptions contains the dial option(s) that control the grpc dialing process
type ErrCollectionNotExists ¶
type ErrCollectionNotExists struct {
// contains filtered or unexported fields
}
ErrCollectionNotExists indicates the collection with specified collection name does not exist
func (ErrCollectionNotExists) Error ¶
func (e ErrCollectionNotExists) Error() string
Error implement error
type ErrPartitionNotExists ¶
type ErrPartitionNotExists struct {
// contains filtered or unexported fields
}
ErrPartitionNotExists indicates the partition of collection does not exist
func (ErrPartitionNotExists) Error ¶
func (e ErrPartitionNotExists) Error() string
Error implement error
type ErrServiceFailed ¶
type ErrServiceFailed error
ErrServiceFailed indicates error returns from milvus service
type SearchResult ¶
type SearchResult struct { ResultCount int // the returning entry count IDs entity.Column // auto generated id, can be mapped to the columns from `Insert` API Fields []entity.Column // output field data Scores []float32 // distance to the target vector Err error // search error if any }
SearchResult contains the result from Search api of client IDs is the auto generated id values for the entities Fields contains the data of `outputFieleds` specified or all columns if non Scores is actually the distance between the vector current record contains and the search target vector
type SearchResultByRows ¶
SearchResultByRows search result for row-based Search
func SearchResultToRows ¶
func SearchResultToRows(sch *entity.Schema, results *schema.SearchResultData, t reflect.Type, output map[string]struct{}) ([]SearchResultByRows, error)
SearchResultToRows converts search result proto to rows