Skip to main content

Create Collection

Creates a collection in a cluster.


POST
https://{cluster-endpoint}/v1/vector/collections/create

Example

Notes

You can use either of the following ways to authorize:

  • An API Key with appropriate permissions.
  • A colon-joined username and password of the target cluster. For example, username:p@ssw0rd.

Currently, data of the JSON and Array types are not supported in RESTful API requests..

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/collections/create" \
--header "Authorization: Bearer ${TOKEN}" \
--header "accept: application/json" \
--header "content-type: application/json" \
-d '{
"dbName": "default",
"collectionName": "medium_articles",
"dimension": 256,
"metricType": "L2",
"primaryField": "id",
"vectorField": "vector"
}'

Success response:

{
"code": 200,
"data": {}
}

Request

Parameters

  • No query parameters required

  • No path parameters required

Request Body

{
"dbName": "string",
"collectionName": "string",
"dimension": "integer",
"metricType": "string",
"primaryField": "string",
"vectorField": "string",
"description": "string"
}
ParameterDescription
dbNamestring
The name of the database. This parameter applies only to dedicated clusters.
collectionNamestring
The name of the collection to create.
dimensioninteger
The number of dimensions for the vector field of the collection. For performance-optimized CUs, this value ranges from 1 to 32768. For capacity-optimized and cost-optimized CUs, this value ranges from 32 to 32768.
The value ranges from 1 to 32768.
metricTypestring
The distance metric used for the collection.
The value defaults to L2
primaryFieldstring
The primary key field.
The value defaults to id
vectorFieldstring
The vector field.
The value defaults to vector
descriptionstring
The description of the collection

Response

Returns an empty object.

Response Bodies

  • Response body if we process your request successfully
{
"code": "integer",
"data": {}
}
  • Response body if we failed to process your request
{
"code": integer,
"message": string
}

Properties

The properties in the returned response are listed in the following table.

PropertyDescription
codeinteger
dataobject
messagestring
Indicates the possible reason for the reported error.

Possible Errors

CodeError Message
80000Incorrect parameter: xxx
80001The token is illegal
80002The token is invalid
80007This CU Size requires significant resource consumption. If you want to use it
80010Duplicated ClusterName. You have already created a running Cluster with the same name. To avoid complexity in management
80014Invalid projectId. The projectId should like proj-xxxxxx
80022Dedicated cluster not support this operation.
90013The parameter shardsNum should have a value range between 1 and 32.
90014The length of parameter description can not exceed 4096.
90015There are no fields. Please include at least 1 primary key field and 1 vector field in the table definition.
90016No primary key field.
90017There can only be one primary key field for each collection.
90018The type of the primary key field must be int64 or varchar.
90019AutoID can only be added to the primary key field.
90020AutoID can only be added to a primary key field of type int64.
90023The length of the Varchar type should be between 1 and 65535.
90025The dimension of the vector column should be between 32 and 32768.
90027Invalid parameter metricType. Only L2 or IP are allowed. Please refer to the documentation: https://milvus.io/docs/metric.md
90100Parse number of field xxx type error.
90102The cluster does not exist in current region.
90106The collection already exists.
90110No filter key field.
90112The field name should not be empty.
90113The field type of field xxx should not be empty.
90114The index field name can only be added to a vector field.
90122No dimension key field.
90136No create collection content provided.
90139Type mismatch for field 'xxx'. expected type:xxx