client

package
v2.3.1-heliumos Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package client provides milvus client functions

Index

Constants

View Source
const (
	StrongTimestamp     uint64 = 0
	EventuallyTimestamp uint64 = 1
	BoundedTimestamp    uint64 = 2
)

Magical timestamps for communicating with server

View Source
const (
	RetryOnRateLimit ctxKey = iota
)

Variables

View Source
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")

	// ErrFeatureNotSupported error indicates current server does not support this feature
	ErrFeatureNotSupported = errors.New("feature not supported")
)
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.

View Source
var (
	// ErrFieldTypeNotMatch error for field type not match
	ErrFieldTypeNotMatch = errors.New("field type not matched")
)
View Source
var MetaCache = metaCache{
	// contains filtered or unexported fields
}

Functions

func PKs2Expr

func PKs2Expr(backName string, ids entity.Column) string

func RetryOnRateLimitInterceptor

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

RetryOnRateLimitInterceptor returns a new retrying unary client interceptor.

func SetFieldValue

func SetFieldValue(field *entity.Field, f reflect.Value, fieldData *schemapb.FieldData, idx int) error

SetFieldValue set row field value with reflection

func WithClientRequestID

func WithClientRequestID(ctx context.Context, reqID string) context.Context

func WithDebugLogLevel

func WithDebugLogLevel(ctx context.Context) context.Context

func WithErrorLogLevel

func WithErrorLogLevel(ctx context.Context) context.Context

func WithInfoLogLevel

func WithInfoLogLevel(ctx context.Context) context.Context

func WithWarnLogLevel

func WithWarnLogLevel(ctx context.Context) context.Context

Types

type BulkInsertOption

type BulkInsertOption func(request *milvuspb.ImportRequest)

BulkInsertOption is an option that is used to modify ImportRequest

func IsBackup

func IsBackup() BulkInsertOption

IsBackup specifies it is triggered by backup tool

func WithEndTs

func WithEndTs(endTs int64) BulkInsertOption

WithEndTs specifies a specific endTs

func WithStartTs

func WithStartTs(startTs int64) BulkInsertOption

WithStartTs specifies a specific startTs

type Client

type Client interface {
	// -- client --
	// Close close the remaining connection resources
	Close() error

	// UsingDatabase for database operation after this function call.
	// All request in any goroutine will be applied to new database on the same client. e.g.
	// 1. goroutine A access DB1.
	// 2. goroutine B call UsingDatabase(ctx, "DB2").
	// 3. goroutine A access DB2 after 2.
	UsingDatabase(ctx context.Context, dbName string) error

	// -- database --
	// ListDatabases list all database in milvus cluster.
	ListDatabases(ctx context.Context) ([]entity.Database, error)
	// CreateDatabase create database with the given name.
	CreateDatabase(ctx context.Context, dbName string) error
	// DropDatabase drop database with the given db name.
	DropDatabase(ctx context.Context, dbName string) error

	// NewCollection intializeds a new collection with pre defined attributes
	NewCollection(ctx context.Context, collName string, dimension int64, opts ...CreateCollectionOption) 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, opts ...CreateCollectionOption) 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, opts ...LoadCollectionOption) 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)
	// RenameCollection performs renaming for provided collection.
	RenameCollection(ctx context.Context, collName, newName string) error
	// AlterCollection changes collection attributes.
	AlterCollection(ctx context.Context, collName string, attrs ...entity.CollectionAttribute) error

	// CreateAlias creates an alias for collection
	CreateAlias(ctx context.Context, collName string, alias string) error
	// DropAlias drops the specified Alias
	DropAlias(ctx context.Context, alias string) error
	// AlterAlias changes collection alias to provided alias
	AlterAlias(ctx context.Context, collName string, alias string) error

	// GetReplicas gets the replica groups as well as their querynodes and shards information
	GetReplicas(ctx context.Context, collName string) ([]*entity.ReplicaGroup, error)

	// CreateCredential create new user and password
	CreateCredential(ctx context.Context, username string, password string) error
	// UpdateCredential update password for a user
	UpdateCredential(ctx context.Context, username string, oldPassword string, newPassword string) error
	// DeleteCredential delete a user
	DeleteCredential(ctx context.Context, username string) error
	// ListCredUsers list all usernames
	ListCredUsers(ctx context.Context) ([]string, 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
	// ShowPartitions 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

	// -- segment --
	GetPersistentSegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, 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, opts ...IndexOption) 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, opts ...IndexOption) ([]entity.Index, error)
	// DropIndex drop index from collection with specified field name
	DropIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) 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, opts ...IndexOption) (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
	// FlushV2 flush collection, specified, return newly sealed segmentIds, all flushed segmentIds of the collection, seal time and error
	// currently it is only used in milvus-backup(https://github.com/zilliztech/milvus-backup)
	FlushV2(ctx context.Context, collName string, async bool) ([]int64, []int64, int64, error)
	// DeleteByPks deletes entries related to provided primary keys
	DeleteByPks(ctx context.Context, collName string, partitionName string, ids entity.Column) error
	// Delete deletes entries match expression
	Delete(ctx context.Context, collName string, partitionName string, expr string) error
	// Upsert column-based data of collection, returns id column values
	Upsert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, 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, opts ...SearchQueryOptionFunc) ([]SearchResult, error)
	// QueryByPks query record by specified primary key(s).
	QueryByPks(ctx context.Context, collectionName string, partitionNames []string, ids entity.Column, outputFields []string, opts ...SearchQueryOptionFunc) (ResultSet, error)
	// Query performs query records with boolean expression.
	Query(ctx context.Context, collectionName string, partitionNames []string, expr string, outputFields []string, opts ...SearchQueryOptionFunc) (ResultSet, error)
	// Get grabs the inserted entities using the primary key from the Collection.
	Get(ctx context.Context, collectionName string, ids entity.Column, opts ...GetOption) (ResultSet, 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)

	// CreateCollectionByRow create collection by row
	CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error
	// DEPRECATED
	// InsertByRows insert by rows
	InsertByRows(ctx context.Context, collName string, paritionName string, rows []entity.Row) (entity.Column, error)
	// InsertRows insert with row base data.
	InsertRows(ctx context.Context, collName string, partitionName string, rows []interface{}) (entity.Column, error)

	// ManualCompaction triggers a compaction on provided collection
	ManualCompaction(ctx context.Context, collName string, toleranceDuration time.Duration) (int64, error)
	// GetCompactionState get compaction state of provided compaction id
	GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error)
	// GetCompactionStateWithPlans get compaction state with plans of provided compaction id
	GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error)

	// BulkInsert import data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments
	BulkInsert(ctx context.Context, collName string, partitionName string, files []string, opts ...BulkInsertOption) (int64, error)
	// GetBulkInsertState checks import task state
	GetBulkInsertState(ctx context.Context, taskID int64) (*entity.BulkInsertTaskState, error)
	// ListBulkInsertTasks list state of all import tasks
	ListBulkInsertTasks(ctx context.Context, collName string, limit int64) ([]*entity.BulkInsertTaskState, error)

	// CreateRole creates a role entity in Milvus.
	CreateRole(ctx context.Context, name string) error
	// DropRole drops a role entity in Milvus.
	DropRole(ctx context.Context, name string) error
	// AddUserRole adds one role for user.
	AddUserRole(ctx context.Context, username string, role string) error
	// RemoveUserRole removes one role from user.
	RemoveUserRole(ctx context.Context, username string, role string) error
	// ListRoles lists the role objects in system.
	ListRoles(ctx context.Context) ([]entity.Role, error)
	// ListUsers lists the user objects in system.
	ListUsers(ctx context.Context) ([]entity.User, error)
	// Grant adds object privileged for role.
	Grant(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

	Grant2(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string, privilege string, dbName string) error
	// Revoke removes privilege from role.
	Revoke(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

	// GetLoadingProgress get the collection or partitions loading progress
	GetLoadingProgress(ctx context.Context, collectionName string, partitionNames []string) (int64, error)
	// GetLoadState get the collection or partitions load state
	GetLoadState(ctx context.Context, collectionName string, partitionNames []string) (entity.LoadState, error)

	// ListResourceGroups returns list of resource group names in current Milvus instance.
	ListResourceGroups(ctx context.Context) ([]string, error)
	// CreateResourceGroup creates a resource group with provided name.
	CreateResourceGroup(ctx context.Context, rgName string) error
	// DescribeResourceGroup returns resource groups information.
	DescribeResourceGroup(ctx context.Context, rgName string) (*entity.ResourceGroup, error)
	// DropResourceGroup drops the resource group with provided name.
	DropResourceGroup(ctx context.Context, rgName string) error
	// TransferNode transfers querynodes between resource groups.
	TransferNode(ctx context.Context, sourceRg, targetRg string, nodesNum int32) error
	// TransferReplica transfer collection replicas between source,target resource group.
	TransferReplica(ctx context.Context, sourceRg, targetRg string, collectionName string, replicaNum int64) error

	// GetVersion get milvus version
	GetVersion(ctx context.Context) (string, error)
}

Client is the interface used to communicate with Milvus

func NewClient

func NewClient(ctx context.Context, config Config) (Client, error)

NewClient create a client connected to remote milvus cluster. More connect option can be modified by Config.

func NewDefaultGrpcClient

func NewDefaultGrpcClient(ctx context.Context, addr string) (Client, error)

NewDefaultGrpcClient creates a new gRPC client. !!!Deprecated in future, use `NewClient` first.

func NewDefaultGrpcClientWithAuth

func NewDefaultGrpcClientWithAuth(ctx context.Context, addr, username, password string) (Client, error)

NewDefaultGrpcClientWithAuth creates a new gRPC client with authentication. !!!Deprecated in future, use `NewClient` first.

func NewDefaultGrpcClientWithTLSAuth

func NewDefaultGrpcClientWithTLSAuth(ctx context.Context, addr, username, password string) (Client, error)

NewDefaultGrpcClientWithTLSAuth creates a new gRPC client with TLS authentication. !!!Deprecated in future, use `NewClient` first.

func NewDefaultGrpcClientWithURI

func NewDefaultGrpcClientWithURI(ctx context.Context, uri, username, password string) (Client, error)

NewDefaultGrpcClientWithURI creates a new gRPC client with URI. !!!Deprecated in future, use `NewClient` first.

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 !!!Deprecated in future, use `NewClient` first.

type Config

type Config struct {
	Address       string // Remote address, "localhost:19530".
	Username      string // Username for auth.
	Password      string // Password for auth.
	DBName        string // DBName for this client.
	Identifier    string // Identifier for this connection
	EnableTLSAuth bool   // Enable TLS Auth for transport security.
	APIKey        string // API key
	ServerVersion string // ServerVersion

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

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

	DisableConn bool
	// contains filtered or unexported fields
}

Config for milvus client.

func (*Config) Copy

func (c *Config) Copy() Config

Copy a new config, dialOption may shared with old config.

type CreateCollectionOption

type CreateCollectionOption func(opt *createCollOpt)

CreateCollectionOption is an option that is used to alter create collection options.

func WithAutoID

func WithAutoID(autoID bool) CreateCollectionOption

func WithCollectionProperty

func WithCollectionProperty(key, value string) CreateCollectionOption

func WithConsistencyLevel

func WithConsistencyLevel(cl entity.ConsistencyLevel) CreateCollectionOption

WithConsistencyLevel specifies a specific ConsistencyLevel, rather than using the default ReaderProperties.

func WithEnableDynamicSchema

func WithEnableDynamicSchema(enable bool) CreateCollectionOption

func WithPKFieldName

func WithPKFieldName(name string) CreateCollectionOption

func WithPKFieldType

func WithPKFieldType(tp entity.FieldType) CreateCollectionOption

func WithPKMaxLength

func WithPKMaxLength(maxLength int64) CreateCollectionOption

func WithPartitionNum

func WithPartitionNum(partitionNums int64) CreateCollectionOption

WithPartitionNum returns a create collection options to set physical partition number when logical partition feature.

func WithVectorFieldName

func WithVectorFieldName(name string) CreateCollectionOption

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 GetOption

type GetOption func(o *getOption)

func GetWithOutputFields

func GetWithOutputFields(outputFields ...string) GetOption

func GetWithPartitions

func GetWithPartitions(partionNames ...string) GetOption

type GrpcClient

type GrpcClient struct {
	Conn    *grpc.ClientConn             // grpc connection instance
	Service milvuspb.MilvusServiceClient // Service client stub
	// contains filtered or unexported fields
}

GrpcClient uses default grpc Service definition to connect with Milvus2.0

func (*GrpcClient) AddUserRole

func (c *GrpcClient) AddUserRole(ctx context.Context, username string, role string) error

AddUserRole adds one role for user.

func (*GrpcClient) AlterAlias

func (c *GrpcClient) AlterAlias(ctx context.Context, collName string, alias string) error

AlterAlias changes collection alias to provided alias

func (*GrpcClient) AlterCollection

func (c *GrpcClient) AlterCollection(ctx context.Context, collName string, attrs ...entity.CollectionAttribute) error

AlterCollection changes the collection attribute.

func (*GrpcClient) BulkInsert

func (c *GrpcClient) BulkInsert(ctx context.Context, collName string, partitionName string, files []string, opts ...BulkInsertOption) (int64, error)

BulkInsert data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments

func (*GrpcClient) CalcDistance

func (c *GrpcClient) CalcDistance(ctx context.Context, collName string, partitions []string,
	metricType entity.MetricType, opLeft, opRight entity.Column) (entity.Column, error)

func (*GrpcClient) Close

func (c *GrpcClient) Close() error

Close close the connection

func (*GrpcClient) CreateAlias

func (c *GrpcClient) CreateAlias(ctx context.Context, collName string, alias string) error

CreateAlias creates an alias for collection

func (*GrpcClient) CreateCollection

func (c *GrpcClient) CreateCollection(ctx context.Context, collSchema *entity.Schema, shardNum int32, opts ...CreateCollectionOption) error

CreateCollection create collection with specified schema

func (*GrpcClient) CreateCollectionByRow

func (c *GrpcClient) CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error

CreateCollectionByRow create collection by row

func (*GrpcClient) CreateCredential

func (c *GrpcClient) CreateCredential(ctx context.Context, username string, password string) error

CreateCredential create new user and password

func (*GrpcClient) CreateDatabase

func (c *GrpcClient) CreateDatabase(ctx context.Context, dbName string) error

CreateDatabase creates a new database for remote Milvus cluster. TODO:New options can be added as expanding parameters.

func (*GrpcClient) CreateIndex

func (c *GrpcClient) CreateIndex(ctx context.Context, collName string, fieldName string,
	idx entity.Index, async bool, opts ...IndexOption) error

CreateIndex create index for collection Deprecated please use CreateIndexV2 instead.

func (*GrpcClient) CreatePartition

func (c *GrpcClient) CreatePartition(ctx context.Context, collName string, partitionName string) error

CreatePartition create partition for collection

func (*GrpcClient) CreateResourceGroup

func (c *GrpcClient) CreateResourceGroup(ctx context.Context, rgName string) error

CreateResourceGroup creates a resource group with provided name.

func (*GrpcClient) CreateRole

func (c *GrpcClient) CreateRole(ctx context.Context, name string) error

CreateRole creates a role entity in Milvus.

func (*GrpcClient) Delete

func (c *GrpcClient) Delete(ctx context.Context, collName string, partitionName string, expr string) error

Delete deletes entries match expression

func (*GrpcClient) DeleteByPks

func (c *GrpcClient) DeleteByPks(ctx context.Context, collName string, partitionName string, ids entity.Column) error

DeleteByPks deletes entries related to provided primary keys

func (*GrpcClient) DeleteCredential

func (c *GrpcClient) DeleteCredential(ctx context.Context, username string) error

DeleteCredential delete a user

func (*GrpcClient) DescribeCollection

func (c *GrpcClient) DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error)

DescribeCollection describe the collection by name

func (*GrpcClient) DescribeIndex

func (c *GrpcClient) DescribeIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) ([]entity.Index, error)

DescribeIndex describe index

func (*GrpcClient) DescribeResourceGroup

func (c *GrpcClient) DescribeResourceGroup(ctx context.Context, rgName string) (*entity.ResourceGroup, error)

DescribeResourceGroup returns resource groups information.

func (*GrpcClient) DropAlias

func (c *GrpcClient) DropAlias(ctx context.Context, alias string) error

DropAlias drops the specified Alias

func (*GrpcClient) DropCollection

func (c *GrpcClient) DropCollection(ctx context.Context, collName string) error

DropCollection drop collection by name

func (*GrpcClient) DropDatabase

func (c *GrpcClient) DropDatabase(ctx context.Context, dbName string) error

DropDatabase drop all database in milvus cluster.

func (*GrpcClient) DropIndex

func (c *GrpcClient) DropIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) error

DropIndex drop index from collection Deprecate please use DropIndexV2 instead.

func (*GrpcClient) DropPartition

func (c *GrpcClient) DropPartition(ctx context.Context, collName string, partitionName string) error

DropPartition drop partition from collection

func (*GrpcClient) DropResourceGroup

func (c *GrpcClient) DropResourceGroup(ctx context.Context, rgName string) error

DropResourceGroup drops the resource group with provided name.

func (*GrpcClient) DropRole

func (c *GrpcClient) DropRole(ctx context.Context, name string) error

DropRole drops a role entity in Milvus.

func (*GrpcClient) Flush

func (c *GrpcClient) Flush(ctx context.Context, collName string, async bool) error

Flush force collection to flush memory records into storage in sync mode, flush will wait all segments to be flushed

func (*GrpcClient) FlushV2

func (c *GrpcClient) FlushV2(ctx context.Context, collName string, async bool) ([]int64, []int64, int64, error)

Flush force collection to flush memory records into storage in sync mode, flush will wait all segments to be flushed

func (*GrpcClient) Get

func (c *GrpcClient) Get(ctx context.Context, collectionName string, ids entity.Column, opts ...GetOption) (ResultSet, error)

Get grabs the inserted entities using the primary key from the Collection.

func (*GrpcClient) GetBulkInsertState

func (c *GrpcClient) GetBulkInsertState(ctx context.Context, taskID int64) (*entity.BulkInsertTaskState, error)

GetBulkInsertState checks import task state

func (*GrpcClient) GetCollectionStatistics

func (c *GrpcClient) GetCollectionStatistics(ctx context.Context, collName string) (map[string]string, error)

GetCollectionStatistcis show collection statistics

func (*GrpcClient) GetCompactionState

func (c *GrpcClient) GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error)

GetCompactionState get compaction state of provided compaction id

func (*GrpcClient) GetCompactionStateWithPlans

func (c *GrpcClient) GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error)

GetCompactionStateWithPlans get compaction state with plans of provided compaction id

func (*GrpcClient) GetIndexBuildProgress

func (c *GrpcClient) GetIndexBuildProgress(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (total, indexed int64, err error)

GetIndexBuildProgress get index building progress

func (*GrpcClient) GetIndexState

func (c *GrpcClient) GetIndexState(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (entity.IndexState, error)

GetIndexState get index state

func (*GrpcClient) GetLoadState

func (c *GrpcClient) GetLoadState(ctx context.Context, collName string, partitionNames []string) (entity.LoadState, error)

GetLoadState get the collection or partitions load state

func (*GrpcClient) GetLoadingProgress

func (c *GrpcClient) GetLoadingProgress(ctx context.Context, collName string, partitionNames []string) (int64, error)

GetLoadingProgress get the collection or partitions loading progress

func (*GrpcClient) GetPersistentSegmentInfo

func (c *GrpcClient) GetPersistentSegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error)

GetPersistentSegmentInfo get persistent segment info

func (*GrpcClient) GetQuerySegmentInfo

func (c *GrpcClient) GetQuerySegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error)

GetQuerySegmentInfo get query query cluster segment loaded info

func (*GrpcClient) GetReplicas

func (c *GrpcClient) GetReplicas(ctx context.Context, collName string) ([]*entity.ReplicaGroup, error)

GetReplicas gets the replica groups as well as their querynodes and shards information

func (*GrpcClient) GetVersion

func (c *GrpcClient) GetVersion(ctx context.Context) (string, error)

GetVersion returns milvus milvuspb.version information.

func (*GrpcClient) Grant

func (c *GrpcClient) Grant(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

Grant adds object privileged for role.

func (*GrpcClient) Grant2

func (c *GrpcClient) Grant2(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string, privilege string, dbName string) error

func (*GrpcClient) HasCollection

func (c *GrpcClient) HasCollection(ctx context.Context, collName string) (bool, error)

HasCollection check whether collection name exists

func (*GrpcClient) HasPartition

func (c *GrpcClient) HasPartition(ctx context.Context, collName string, partitionName string) (bool, error)

HasPartition check whether specified partition exists

func (*GrpcClient) Insert

func (c *GrpcClient) Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error)

Insert Index into collection with column-based format collName is the collection name partitionName is the partition to insert, if not specified(empty), default partition will be used columns are slice of the column-based data

func (*GrpcClient) InsertByRows

func (c *GrpcClient) InsertByRows(ctx context.Context, collName string, partitionName string,
	rows []entity.Row) (entity.Column, error)

InsertByRows insert by rows

func (*GrpcClient) InsertRows

func (c *GrpcClient) InsertRows(ctx context.Context, collName string, partitionName string,
	rows []interface{}) (entity.Column, error)

InsertRows allows insert with row based data rows could be struct or map.

func (*GrpcClient) ListBulkInsertTasks

func (c *GrpcClient) ListBulkInsertTasks(ctx context.Context, collName string, limit int64) ([]*entity.BulkInsertTaskState, error)

ListBulkInsertTasks list state of all import tasks

func (*GrpcClient) ListCollections

func (c *GrpcClient) ListCollections(ctx context.Context) ([]*entity.Collection, error)

ListCollections list collections from connection Note that schema info are not provided in collection list

func (*GrpcClient) ListCredUsers

func (c *GrpcClient) ListCredUsers(ctx context.Context) ([]string, error)

ListCredUsers list all usernames

func (*GrpcClient) ListDatabases

func (c *GrpcClient) ListDatabases(ctx context.Context) ([]entity.Database, error)

ListDatabases list all database in milvus cluster.

func (*GrpcClient) ListResourceGroups

func (c *GrpcClient) ListResourceGroups(ctx context.Context) ([]string, error)

ListResourceGroups returns list of resource group names in current Milvus instance.

func (*GrpcClient) ListRoles

func (c *GrpcClient) ListRoles(ctx context.Context) ([]entity.Role, error)

ListRoles lists the role objects in system.

func (*GrpcClient) ListUsers

func (c *GrpcClient) ListUsers(ctx context.Context) ([]entity.User, error)

ListUsers lists the user objects in system.

func (*GrpcClient) LoadCollection

func (c *GrpcClient) LoadCollection(ctx context.Context, collName string, async bool, opts ...LoadCollectionOption) error

LoadCollection load collection into memory

func (*GrpcClient) LoadPartitions

func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partitionNames []string, async bool) error

LoadPartitions load collection paritions into memory

func (*GrpcClient) ManualCompaction

func (c *GrpcClient) ManualCompaction(ctx context.Context, collName string, _ time.Duration) (int64, error)

ManualCompaction triggers a compaction on provided collection

func (*GrpcClient) NewCollection

func (c *GrpcClient) NewCollection(ctx context.Context, collName string, dimension int64, opts ...CreateCollectionOption) error

NewCollection creates a common simple collection with pre-defined attributes.

func (*GrpcClient) Query

func (c *GrpcClient) Query(ctx context.Context, collectionName string, partitionNames []string, expr string, outputFields []string, opts ...SearchQueryOptionFunc) (ResultSet, error)

Query performs query by expression.

func (*GrpcClient) QueryByPks

func (c *GrpcClient) QueryByPks(ctx context.Context, collectionName string, partitionNames []string, ids entity.Column, outputFields []string, opts ...SearchQueryOptionFunc) (ResultSet, error)

QueryByPks query record by specified primary key(s)

func (*GrpcClient) ReleaseCollection

func (c *GrpcClient) ReleaseCollection(ctx context.Context, collName string) error

ReleaseCollection release loaded collection

func (*GrpcClient) ReleasePartitions

func (c *GrpcClient) ReleasePartitions(ctx context.Context, collName string, partitionNames []string) error

ReleasePartitions release partitions

func (*GrpcClient) RemoveUserRole

func (c *GrpcClient) RemoveUserRole(ctx context.Context, username string, role string) error

RemoveUserRole removes one role from user.

func (*GrpcClient) RenameCollection

func (c *GrpcClient) RenameCollection(ctx context.Context, collName, newName string) error

RenameCollection performs renaming for provided collection.

func (*GrpcClient) Revoke

func (c *GrpcClient) Revoke(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

Revoke removes privilege from role.

func (*GrpcClient) Search

func (c *GrpcClient) 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, opts ...SearchQueryOptionFunc) ([]SearchResult, error)

Search with bool expression

func (*GrpcClient) ShowCollection

func (c *GrpcClient) ShowCollection(ctx context.Context, collName string) (*entity.Collection, error)

ShowCollection show collection status, used to check whether it is loaded or not

func (*GrpcClient) ShowPartitions

func (c *GrpcClient) ShowPartitions(ctx context.Context, collName string) ([]*entity.Partition, error)

ShowPartitions list all partitions from collection

func (*GrpcClient) TransferNode

func (c *GrpcClient) TransferNode(ctx context.Context, sourceRg, targetRg string, nodesNum int32) error

TransferNode transfers querynodes between resource groups.

func (*GrpcClient) TransferReplica

func (c *GrpcClient) TransferReplica(ctx context.Context, sourceRg, targetRg string, collectionName string, replicaNum int64) error

TransferReplica transfer collection replicas between source,target resource group.

func (*GrpcClient) UpdateCredential

func (c *GrpcClient) UpdateCredential(ctx context.Context, username string, oldPassword string, newPassword string) error

UpdateCredential update password for a user

func (*GrpcClient) Upsert

func (c *GrpcClient) Upsert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error)

Upsert Index into collection with column-based format collName is the collection name partitionName is the partition to upsert, if not specified(empty), default partition will be used columns are slice of the column-based data

func (*GrpcClient) UsingDatabase

func (c *GrpcClient) UsingDatabase(ctx context.Context, dbName string) error

UsingDatabase for database operation after this function call. All request in any goroutine will be applied to new database on the same client. e.g. 1. goroutine A access DB1. 2. goroutine B call UsingDatabase(ctx, "DB2"). 3. goroutine A access DB2 after 2.

type IndexOption

type IndexOption func(*indexDef)

IndexOption is the predefined function to alter index def. shared among create, describe, drop indexes operations.

func WithIndexName

func WithIndexName(name string) IndexOption

WithIndexName returns an IndexOption with customized index name.

type LoadCollectionOption

type LoadCollectionOption func(*milvuspb.LoadCollectionRequest)

LoadCollectionOption is an option that is used to modify LoadCollectionRequest

func WithReplicaNumber

func WithReplicaNumber(rn int32) LoadCollectionOption

WithReplicaNumber specifies a specific ReplicaNumber, rather than using the default ReplicaNumber.

func WithResourceGroups

func WithResourceGroups(rgs []string) LoadCollectionOption

WithResourceGroups specifies some specific ResourceGroup(s) to load the replica(s), rather than using the default ResourceGroup.

type ResultSet

type ResultSet []entity.Column

ResultSet is an alias type for column slice.

func (ResultSet) GetColumn

func (rs ResultSet) GetColumn(fieldName string) entity.Column

GetColumn returns column with provided field name.

type RetryRateLimitOption

type RetryRateLimitOption struct {
	MaxRetry   uint
	MaxBackoff time.Duration
}

type SearchQueryOption

type SearchQueryOption struct {
	// Consistency Level
	ConsistencyLevel   entity.ConsistencyLevel
	GuaranteeTimestamp uint64
	// Pagination
	Limit  int64
	Offset int64

	IgnoreGrowing bool
	ForTuning     bool
}

SearchQueryOption is an option of search/query request

type SearchQueryOptionFunc

type SearchQueryOptionFunc func(option *SearchQueryOption)

SearchQueryOptionFunc is a function which modifies SearchOption

func WithForTuning

func WithForTuning() SearchQueryOptionFunc

func WithGuaranteeTimestamp

func WithGuaranteeTimestamp(gt uint64) SearchQueryOptionFunc

WithGuaranteeTimestamp specifies guarantee timestamp

func WithIgnoreGrowing

func WithIgnoreGrowing() SearchQueryOptionFunc

func WithLimit

func WithLimit(limit int64) SearchQueryOptionFunc

WithLimit returns search/query option with limit.

func WithOffset

func WithOffset(offset int64) SearchQueryOptionFunc

WithOffset returns search/query option with offset.

func WithSearchQueryConsistencyLevel

func WithSearchQueryConsistencyLevel(cl entity.ConsistencyLevel) SearchQueryOptionFunc

WithSearchQueryConsistencyLevel specifies consistency level

func WithTravelTimestamp deprecated

func WithTravelTimestamp(_ uint64) SearchQueryOptionFunc

Deprecated: time travel is not supported since v2.3.0

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      ResultSet     //[]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

type SearchResultByRows struct {
	ResultCount int
	Scores      []float32
	Rows        []entity.Row
	Err         error
}

SearchResultByRows search result for row-based Search

func SearchResultToRows

func SearchResultToRows(sch *entity.Schema, results *schemapb.SearchResultData, t reflect.Type, _ map[string]struct{}) ([]SearchResultByRows, error)

SearchResultToRows converts search result proto to rows

Jump to

Keyboard shortcuts

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