Create Collection
This operation creates a collection in a specified cluster.
The base URL for this API is in the following format:
https://${CLUSTER_ENDPOINT}
- You need to fill in
${CLUSTER_ENDPOINT}
with that of your Zilliz Cloud cluster. - To get the endpoint, refer to On Zilliz Cloud Console or use the Describe Cluster V2 API to extract the values from the responses.
export CLUSTER_ENDPOINT=""
The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password
.
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.FLOATVECTOR or **DataType.BinaryVECTOR.
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 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.
Whether allows the primary field to automatically increment. Setting this to True makes the primary field automatically increment. In this case, the primary field should not be included in the data to insert to avoid errors. Set this parameter in the field with is_primary set to True.
Whether allows to use the reserved $meta field to hold non-schema-defined fields in key-value pairs.
A list of field objects.
A field object
The name of the field to create in the target collection
The data type of the field values.
The data type of the elements in an array field. This is required if the current field is of the array type.
Whether the current field is the primary field. Setting this to True makes the current field the primary field.
Whether the current field serves as the partition key. Setting this to True makes the current field serve as the partition key. In this case, manages all partitions in the current collection.
Extra field parameters.
An optional parameter for VarChar values that determines the maximum length of the value in the current field.
An optional parameter for FloatVector or BinaryVector fields that determines the vector dimension.
An optional parameter for Array field values that determines the maximum number of elements in the current array field.
The parameters that apply to the index-building process.
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 maximum number of characters in a VarChar field. This parameter is mandatory when the current field type is VarChar.
Whether to enable the reserved dynamic field. If set to true, non-schema-defined fields are saved in the reserved dynamic field as key-value pairs.
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.
Whether to enable partition key isolation. For details, refer to Use Partition Key.
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}" \
--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 "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.
Response payload which is an empty object.
A failure response.
Response code.
Error message.
{
"code": 0,
"data": {}
}