client

package module
v2.0.0-...-2c7bb0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package milvusclient implements the official Go Milvus client for v2.

Index

Constants

View Source
const (
	RetryOnRateLimit ctxKey = iota
)

Variables

View Source
var DefaultGrpcOpts = []grpc.DialOption{
	grpc.WithBlock(),
	grpc.WithKeepaliveParams(keepalive.ClientParameters{
		Time:                5 * time.Second,
		Timeout:             10 * time.Second,
		PermitWithoutStream: true,
	}),
	grpc.WithConnectParams(grpc.ConnectParams{
		Backoff: backoff.Config{
			BaseDelay:  100 * time.Millisecond,
			Multiplier: 1.6,
			Jitter:     0.2,
			MaxDelay:   3 * time.Second,
		},
		MinConnectTimeout: 3 * time.Second,
	}),
}

DefaultGrpcOpts is GRPC options for milvus client.

Functions

func NewColumnBasedInsertOption

func NewColumnBasedInsertOption(collName string, columns ...column.Column) *columnBasedDataOption

func NewCreateCollectionOption

func NewCreateCollectionOption(name string, collectionSchema *entity.Schema) *createCollectionOption

NewCreateCollectionOption returns a CreateCollectionOption with customized collection schema

func NewCreateDatabaseOption

func NewCreateDatabaseOption(dbName string) *createDatabaseOption

func NewCreateIndexOption

func NewCreateIndexOption(collectionName string, fieldName string, index index.Index) *createIndexOption

func NewCreatePartitionOption

func NewCreatePartitionOption(collectionName string, partitionName string) *createPartitionOpt

func NewDeleteOption

func NewDeleteOption(collectionName string) *deleteOption

func NewDescribeCollectionOption

func NewDescribeCollectionOption(name string) *describeCollectionOption

NewDescribeCollectionOption composes a describeCollectionOption with provided collection name.

func NewDescribeIndexOption

func NewDescribeIndexOption(collectionName string, indexName string) *describeIndexOption

func NewDropCollectionOption

func NewDropCollectionOption(name string) *dropCollectionOption

func NewDropDatabaseOption

func NewDropDatabaseOption(dbName string) *dropDatabaseOption

func NewDropIndexOption

func NewDropIndexOption(collectionName string, indexName string) *dropIndexOption

func NewDropPartitionOption

func NewDropPartitionOption(collectionName string, partitionName string) *dropPartitionOpt

func NewFlushOption

func NewFlushOption(collName string) *flushOption

func NewHasPartitionOption

func NewHasPartitionOption(collectionName string, partitionName string) *hasPartitionOpt

func NewListCollectionOption

func NewListCollectionOption() *listCollectionOption

func NewListDatabaseOption

func NewListDatabaseOption() *listDatabaseOption

func NewListIndexOption

func NewListIndexOption(collectionName string) *listIndexOption

func NewListPartitionOption

func NewListPartitionOption(collectionName string) *listPartitionsOpt

func NewLoadCollectionOption

func NewLoadCollectionOption(collectionName string) *loadCollectionOption

func NewLoadPartitionsOption

func NewLoadPartitionsOption(collectionName string, partitionsNames []string) *loadPartitionsOption

func NewQueryOption

func NewQueryOption(collectionName string) *queryOption

func NewRowBasedInsertOption

func NewRowBasedInsertOption(collName string, rows ...any) *rowBasedDataOption

func NewSearchOption

func NewSearchOption(collectionName string, limit int, vectors []entity.Vector) *searchOption

func NewUsingDatabaseOption

func NewUsingDatabaseOption(dbName string) *usingDatabaseNameOpt

func RetryOnRateLimitInterceptor

func RetryOnRateLimitInterceptor(maxRetry uint, maxBackoff time.Duration, backoffFunc grpc_retry.BackoffFuncContext) grpc.UnaryClientInterceptor

RetryOnRateLimitInterceptor returns a new retrying unary client interceptor.

func SimpleCreateCollectionOptions

func SimpleCreateCollectionOptions(name string, dim int64) *createCollectionOption

SimpleCreateCollectionOptions returns a CreateCollectionOption with default fast collection options.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, config *ClientConfig) (*Client, error)

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) CreateCollection

func (c *Client) CreateCollection(ctx context.Context, option CreateCollectionOption, callOptions ...grpc.CallOption) error

CreateCollection is the API for create a collection in Milvus.

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, option CreateDatabaseOption, callOptions ...grpc.CallOption) error

func (*Client) CreateIndex

func (c *Client) CreateIndex(ctx context.Context, option CreateIndexOption, callOptions ...grpc.CallOption) (*CreateIndexTask, error)

func (*Client) CreatePartition

func (c *Client) CreatePartition(ctx context.Context, opt CreatePartitionOption, callOptions ...grpc.CallOption) error

CreatePartition is the API for creating a partition for a collection.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, option DeleteOption, callOptions ...grpc.CallOption) (DeleteResult, error)

func (*Client) DescribeCollection

func (c *Client) DescribeCollection(ctx context.Context, option DescribeCollectionOption, callOptions ...grpc.CallOption) (collection *entity.Collection, err error)

func (*Client) DescribeIndex

func (c *Client) DescribeIndex(ctx context.Context, opt DescribeIndexOption, callOptions ...grpc.CallOption) (index.Index, error)

func (*Client) DropCollection

func (c *Client) DropCollection(ctx context.Context, option DropCollectionOption, callOptions ...grpc.CallOption) error

func (*Client) DropDatabase

func (c *Client) DropDatabase(ctx context.Context, option DropDatabaseOption, callOptions ...grpc.CallOption) error

func (*Client) DropIndex

func (c *Client) DropIndex(ctx context.Context, opt DropIndexOption, callOptions ...grpc.CallOption) error

func (*Client) DropPartition

func (c *Client) DropPartition(ctx context.Context, opt DropPartitionOption, callOptions ...grpc.CallOption) error

func (*Client) Flush

func (c *Client) Flush(ctx context.Context, option FlushOption, callOptions ...grpc.CallOption) (*FlushTask, error)

func (*Client) HasCollection

func (c *Client) HasCollection(ctx context.Context, option HasCollectionOption, callOptions ...grpc.CallOption) (has bool, err error)

func (*Client) HasPartition

func (c *Client) HasPartition(ctx context.Context, opt HasPartitionOption, callOptions ...grpc.CallOption) (has bool, err error)

func (*Client) Insert

func (c *Client) Insert(ctx context.Context, option InsertOption, callOptions ...grpc.CallOption) (InsertResult, error)

func (*Client) ListCollections

func (c *Client) ListCollections(ctx context.Context, option ListCollectionOption, callOptions ...grpc.CallOption) (collectionNames []string, err error)

func (*Client) ListDatabase

func (c *Client) ListDatabase(ctx context.Context, option ListDatabaseOption, callOptions ...grpc.CallOption) (databaseNames []string, err error)

func (*Client) ListIndexes

func (c *Client) ListIndexes(ctx context.Context, opt ListIndexOption, callOptions ...grpc.CallOption) ([]string, error)

func (*Client) ListPartitions

func (c *Client) ListPartitions(ctx context.Context, opt ListPartitionsOption, callOptions ...grpc.CallOption) (partitionNames []string, err error)

func (*Client) LoadCollection

func (c *Client) LoadCollection(ctx context.Context, option LoadCollectionOption, callOptions ...grpc.CallOption) (LoadTask, error)

func (*Client) LoadPartitions

func (c *Client) LoadPartitions(ctx context.Context, option LoadPartitionsOption, callOptions ...grpc.CallOption) (LoadTask, error)

func (*Client) MetadataUnaryInterceptor

func (c *Client) MetadataUnaryInterceptor() grpc.UnaryClientInterceptor

func (*Client) Query

func (c *Client) Query(ctx context.Context, option QueryOption, callOptions ...grpc.CallOption) (ResultSet, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, option SearchOption, callOptions ...grpc.CallOption) ([]ResultSet, error)

func (*Client) Upsert

func (c *Client) Upsert(ctx context.Context, option UpsertOption, callOptions ...grpc.CallOption) (UpsertResult, error)

func (*Client) UsingDatabase

func (c *Client) UsingDatabase(ctx context.Context, option UsingDatabaseOption) error

type ClientConfig

type ClientConfig struct {
	Address  string // Remote address, "localhost:19530".
	Username string // Username for auth.
	Password string // Password for auth.
	DBName   string // DBName for this client.

	EnableTLSAuth bool   // Enable TLS Auth for transport security.
	APIKey        string // API key

	DialOptions []grpc.DialOption // Dial options for GRPC.

	RetryRateLimit *RetryRateLimitOption // option for retry on rate limit inteceptor

	DisableConn bool

	ServerVersion string // ServerVersion
	// contains filtered or unexported fields
}

ClientConfig for milvus client.

type CollectionCache

type CollectionCache struct {
	// contains filtered or unexported fields
}

CollectionCache stores the cached collection schema information.

func NewCollectionCache

func NewCollectionCache(fetcher func(context.Context, string) (*entity.Collection, error)) *CollectionCache

func (*CollectionCache) GetCollection

func (c *CollectionCache) GetCollection(ctx context.Context, collName string) (*entity.Collection, error)

type CreateCollectionOption

type CreateCollectionOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.CreateCollectionRequest
	// Indexes is the method returns IndexOption to create
	Indexes() []CreateIndexOption
	IsFast() bool
}

CreateCollectionOption is the interface builds CreateCollectionRequest.

type CreateDatabaseOption

type CreateDatabaseOption interface {
	Request() *milvuspb.CreateDatabaseRequest
}

type CreateIndexOption

type CreateIndexOption interface {
	Request() *milvuspb.CreateIndexRequest
}

type CreateIndexTask

type CreateIndexTask struct {
	// contains filtered or unexported fields
}

func (*CreateIndexTask) Await

func (t *CreateIndexTask) Await(ctx context.Context) error

type CreatePartitionOption

type CreatePartitionOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.CreatePartitionRequest
}

CreatePartitionOption is the interface builds Create Partition request.

type DataSet

type DataSet []column.Column

DataSet is an alias type for column slice.

type DeleteOption

type DeleteOption interface {
	Request() *milvuspb.DeleteRequest
}

type DeleteResult

type DeleteResult struct {
	DeleteCount int64
}

type DescribeCollectionOption

type DescribeCollectionOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.DescribeCollectionRequest
}

DescribeCollectionOption is the interface builds DescribeCollection request.

type DescribeIndexOption

type DescribeIndexOption interface {
	Request() *milvuspb.DescribeIndexRequest
}

type DropCollectionOption

type DropCollectionOption interface {
	Request() *milvuspb.DropCollectionRequest
}

The DropCollectionOption interface builds DropCollectionRequest.

type DropDatabaseOption

type DropDatabaseOption interface {
	Request() *milvuspb.DropDatabaseRequest
}

type DropIndexOption

type DropIndexOption interface {
	Request() *milvuspb.DropIndexRequest
}

type DropPartitionOption

type DropPartitionOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.DropPartitionRequest
}

DropPartitionOption is the interface that builds Drop Partition request.

type FlushOption

type FlushOption interface {
	Request() *milvuspb.FlushRequest
	CollectionName() string
	CheckInterval() time.Duration
}

type FlushTask

type FlushTask struct {
	// contains filtered or unexported fields
}

func (*FlushTask) Await

func (t *FlushTask) Await(ctx context.Context) error

type HasCollectionOption

type HasCollectionOption interface {
	Request() *milvuspb.DescribeCollectionRequest
}

HasCollectionOption is the interface to build DescribeCollectionRequest.

func NewHasCollectionOption

func NewHasCollectionOption(name string) HasCollectionOption

type HasPartitionOption

type HasPartitionOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.HasPartitionRequest
}

HasPartitionOption is the interface builds HasPartition request.

type InsertOption

type InsertOption interface {
	InsertRequest(coll *entity.Collection) (*milvuspb.InsertRequest, error)
	CollectionName() string
}

type InsertResult

type InsertResult struct {
	InsertCount int64
	IDs         column.Column
}

type ListCollectionOption

type ListCollectionOption interface {
	Request() *milvuspb.ShowCollectionsRequest
}

type ListDatabaseOption

type ListDatabaseOption interface {
	Request() *milvuspb.ListDatabasesRequest
}

ListDatabaseOption is a builder interface for ListDatabase request.

type ListIndexOption

type ListIndexOption interface {
	Request() *milvuspb.DescribeIndexRequest
	Matches(*milvuspb.IndexDescription) bool
}

type ListPartitionsOption

type ListPartitionsOption interface {
	// Request is the method returns the composed request.
	Request() *milvuspb.ShowPartitionsRequest
}

ListPartitionsOption is the interface builds List Partition request.

type LoadCollectionOption

type LoadCollectionOption interface {
	Request() *milvuspb.LoadCollectionRequest
	CheckInterval() time.Duration
}

type LoadPartitionsOption

type LoadPartitionsOption interface {
	Request() *milvuspb.LoadPartitionsRequest
	CheckInterval() time.Duration
}

type LoadTask

type LoadTask struct {
	// contains filtered or unexported fields
}

func (*LoadTask) Await

func (t *LoadTask) Await(ctx context.Context) error

type QueryOption

type QueryOption interface {
	Request() *milvuspb.QueryRequest
}

type ResultSet

type ResultSet struct {
	ResultCount  int // the returning entry count
	GroupByValue column.Column
	IDs          column.Column // auto generated id, can be mapped to the columns from `Insert` API
	Fields       DataSet       // output field data
	Scores       []float32     // distance to the target vector
	Err          error         // search error if any
}

type ResultSets

type ResultSets struct{}

type RetryRateLimitOption

type RetryRateLimitOption struct {
	MaxRetry   uint
	MaxBackoff time.Duration
}

type SearchOption

type SearchOption interface {
	Request() *milvuspb.SearchRequest
}

type UpsertOption

type UpsertOption interface {
	UpsertRequest(coll *entity.Collection) (*milvuspb.UpsertRequest, error)
	CollectionName() string
}

type UpsertResult

type UpsertResult struct {
	UpsertCount int64
	IDs         column.Column
}

type UsingDatabaseOption

type UsingDatabaseOption interface {
	DbName() string
}

Directories

Path Synopsis
Code generated by go generate; DO NOT EDIT This file is generated by go generated
Code generated by go generate; DO NOT EDIT This file is generated by go generated
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL