Skip to main content

Create Collection

This operation creates a collection in a specified cluster.

POST
/v2/vectordb/collections/create
Cluster Endpoint

The base URL for this API is in the following format:

https://${CLUSTER_ENDPOINT}

📘Notes
export CLUSTER_ENDPOINT=""
Parameters
Authorizationstringheaderrequired

The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password.

Example Value: Bearer {{TOKEN}}
Request Bodyapplication/json
collectionNamestringrequired

The name of the collection to create.

dimensionintegerrequired

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.

metricTypestring

The metric type applied to this operation.

idTypestring

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.

autoIDstring

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.

primaryFieldNamestring

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.

vectorFieldNamestring

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.

collectionNamestring

The name of the collection to create.

schemaobject

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.

autoIDstring

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.

enableDynamicFieldstring

Whether allows to use the reserved $meta field to hold non-schema-defined fields in key-value pairs.

fieldsarrayrequired

A list of field objects.

[]fieldsobjectrequired

A field object

fieldNamestringrequired

The name of the field to create in the target collection

dataTypestringrequired

The data type of the field values.

elementDataTypestring

The data type of the elements in an array field. This is required if the current field is of the array type.

isPrimaryboolean

Whether the current field is the primary field. Setting this to True makes the current field the primary field.

isPartitionKeyboolean

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.

elementTypeParamsobject

Extra field parameters.

max_lengthinteger

An optional parameter for VarChar values that determines the maximum length of the value in the current field.

diminteger

An optional parameter for FloatVector or BinaryVector fields that determines the vector dimension.

max_capacityinteger

An optional parameter for Array field values that determines the maximum number of elements in the current array field.

indexParamsarray

The parameters that apply to the index-building process.

[]indexParamsobject
metricTypestringrequired

The similarity metric type used to build the index. For more information, refer to Similarity Metrics Explained](/docs/search-metrics-explained).

fieldNamestringrequired

The name of the target field on which an index is to be created.

indexNamestringrequired

The name of the index to create. The value defaults to the target field name.

paramsobject

The index type and related settings. For Zilliz Cloud clusters, you should always set index_type to AUTOINDEX.

index_typestringrequired

The type of the index to create

paramsobject

Extra parameters for the collection.

max_lengthinteger

The maximum number of characters in a VarChar field. This parameter is mandatory when the current field type is VarChar.

enableDynamicFieldboolean

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.

consistencyLevelinteger

The consistency level of the collection.

partitionsNuminteger

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.

ttlSecondsinteger

The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.

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"
}
}'
Responses200 - application/json
codeinteger

Response code.

dataobject

Response payload which is an empty object.

A failure response.

codeinteger

Response code.

messagestring

Error message.

{
"code": 0,
"data": {}
}