Create Collection (V2)
This operation creates a collection in a specified cluster.
The base URL for this API is in the following format:
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
- Use the cluster endpoint if you are using serving clusters.
Free & Serverless
https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.comDedicated
https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530
- You need to fill in
${CLUSTER_ENDPOINT}with that of your Zilliz Cloud cluster. - To get the endpoint, use the Describe Cluster V2 API to extract the values from the responses.
export CLUSTER_ENDPOINT="https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530"
The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password. If you are using a project endpoint, only a valid API key with sufficient permissions applies.
The name of the database.
The name of the collection to create.
The number of dimensions a vector value should have. This is required if dtype of this field is set to DataType.FLOAT_VECTOR or DataType.Binary_VECTOR.
The metric type applied to this operation.
The data type of the primary field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.
Whether the primary field automatically increments. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.
The name of the primary field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.
The name of the vector field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.
The description of the current collection.
Extra parameters for the collection.
The maximum number of bytes allowed in the primary field. This parameter is available only when the primary field is a string field.
Whether to enable the dynamic field feature.
The consistency level of the collection.
The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.
Specifies whether to enable memory mapping for the collection.
The name of the field to use for TTL-based expiration.
Whether to preload scalar field data into memory on load.
Whether to preload scalar index data into memory on load.
Whether to preload vector field data into memory on load.
Whether to preload vector index data into memory on load.
The name of the database.
The name of the collection to create.
The schema is responsible for organizing data in the target collection. A valid schema should have multiple fields, which must include a primary key, a vector field, and several scalar fields. Setting this parameter means that dimension, idType, autoID, primaryFieldName, and vectorFieldName will be ignored.
The parameters that apply to the index-building process.
An index Schema object.
The similarity metric type used to build the index. For more information, refer to Similarity Metrics Explained](/docs/search-metrics-explained).
The name of the target field on which an index is to be created.
The name of the index to create. The value defaults to the target field name.
The index type and related settings. For Zilliz Cloud clusters, you should always set index_type to AUTOINDEX.
The type of the index to create
Extra parameters for the collection.
The consistency level of the collection.
The number of partitions to create along with the current collection. This parameter is mandatory if one field of the collection has been designated as the partition key.
The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.
Specifies whether to enable partition key isolation for the collection.
Specifies whether to enable memory mapping for the collection.
The name of the field to use for TTL-based expiration.
Whether to preload scalar field data into memory on load.
Whether to preload scalar index data into memory on load.
Whether to preload vector field data into memory on load.
Whether to preload vector index data into memory on load.
The description of the current collection.
The name of the database.
The name of the collection to create.
The schema for an external collection. Must include fields with externalField mappings, plus externalSource and externalSpec.
The parameters that apply to the index-building process.
An index Schema object.
The similarity metric type used to build the index. For more information, refer to Similarity Metrics Explained](/docs/search-metrics-explained).
The name of the target field on which an index is to be created.
The name of the index to create. The value defaults to the target field name.
The index type and related settings. For Zilliz Cloud clusters, you should always set index_type to AUTOINDEX.
The type of the index to create
Extra parameters for the collection.
The consistency level of the collection.
The number of partitions to create along with the current collection. This parameter is mandatory if one field of the collection has been designated as the partition key.
The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.
Specifies whether to enable partition key isolation for the collection.
Specifies whether to enable memory mapping for the collection.
The name of the field to use for TTL-based expiration.
Whether to preload scalar field data into memory on load.
Whether to preload scalar index data into memory on load.
Whether to preload vector field data into memory on load.
Whether to preload vector index data into memory on load.
The description of the current collection.
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}". \
--header "Request-Timeout: 10" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "test_collection",
"dimension": 5
}'
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}". \
--header "Request-Timeout: 10" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "custom_quick_setup",
"dimension": 5,
"primaryFieldName": "my_id",
"idType": "VarChar",
"vectorFieldName": "my_vector",
"metric_type": "L2",
"autoId": true,
"params": {
"max_length": "512"
}
}'
Response code.
Returns an error message.
Response code.
Error message.
{
"code": 0,
"data": {}
}