NewCollection()即将作废
This method creates a collection in a Zilliz Cloud cluster.
func (c *GrpcClient) NewCollection(ctx context.Context, collName string, dimension int64, opts ...CreateCollectionOption) error
Request Parameters
| Parameter | Description | Type | 
|---|---|---|
| 
 | Context for the current call to work. | 
 | 
| 
 | Name of the collection to create. | 
 | 
| 
 | Dimensionality of the vector field. | 
 | 
| 
 | Extra options for the current request. This parameter is optional. You can add multiple  | 
 | 
entity.CreateCollectionOption
You can add extra collection settings to the NewCollection() request using the following methods.
| Method | Description | 
|---|---|
| 
 | Whether allows Zilliz Cloud to automatically generate IDs upon data insertions. | 
| 
 | Metric type for Zilliz Cloud to measure similarity between vector embeddings. | 
| 
 | Custom name of the primary field. If not specified, the default value  | 
| 
 | Data type of the primary field. If not specified, the default value entity  | 
| 
 | Maximum length of the values in the primary field. This is required only when you set  | 
| 
 | Custom name of the vector field. If not specified, the default value  | 
Return
Null
Errors
Any error in the execution of the request. Possible errors are as follows:
- 
ErrClientNotReady: The client is not connected to Milvus.
- 
A collection with the same name already exists. 
- 
The call to this API fails. 
Example
var collectionName = "test_01"
errNew := mc.NewCollection(context.Background(), collectionName, 768, client.WithConsistencyLevel(entity.ClBounded))
if errNew != nil {
   log.Fatal("failed to New collection:", errNew.Error())
}