milvus-logo
LFAI
< Docs
  • Go

LoadCollection()

This method loads the specified collection to memory (for search and query).

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

Request Parameters

Parameter

Description

Type

ctx

Context for the current call to work.

context.Context

collName

Name of the collection to load.

string

async

Whether to execute this request asynchronously.

bool

opts

Extra settings for this request.

client.LoadCollectionOption

client.LoadCollectionOption

You can add extra settings to the LoadCollection() request using the following methods.

Method

Description

WithReplicaNumber(rn int32)

Number of replicas to create upon the load of the collection.

WithResourceGroups(rgs []string)

A list of specific resource groups used to load the replicas.

Return

Null

Errors

Any error in the execution of the request. Possible errors are as follows:

  • ErrClientNotReady: The client is not connected to Milvus.

  • ErrCollectionNotExists: The collection with the specified name does not exist.

  • The call to this API fails.

Example

// load collection
errLoad := mc.LoadCollection(context.Background(), collectionName, false, client.WithReplicaNumber(1))
if errLoad != nil {
   log.Fatal("failed to load collection:", errLoad.Error())
}

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?