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.
Defines a Collection to be created with a quick setup. collectionName and dimension are required.
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 idType of this field is set to FloatVector or 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 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 consistency level applied to the collection described by this setup. It determines the consistency guarantee used when the collection is queried.
Additional properties of the Collection. Use it to specify extra settings for the Collection.
The vector data type used for the vector field of the Collection created by quick setup.
A Collection setup whose configuration is supplied explicitly, including the required collectionName.
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.
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 schema 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 field can be null. If set to true, the field can contain null values.
The default value of the field. This is required if the current field is of the VarChar 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, Zilliz Cloud 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.
A list of functions.
A function schema object.
The name of the function to create.
The description of the function to create.
The type of the function to create.
The names of the input fields for the function to create.
A field name.
The names of the output fields for the function to create.
A field name.
Configuration parameters specific to the current function. Once the function type is set to BM25, no parameter is required. For applicable parameters to functions of TEXTEMBEDDING or RERANK, refer to Embedding Functions and Reranking Functions
A list of struct array fields.
A struct array field that groups multiple sub-fields.
The name of the struct array field.
A description of the struct array field.
The sub-fields in the struct array. Each dataType refers to the scalar or vector type of a struct field.
A sub-field definition within a struct array. The dataType refers to the scalar or vector type of each struct field.
The name of the sub-field.
The scalar or vector type of the struct field.
Parameters for the element type, such as max_length for VarChar or dim for vector types.
Parameters of the struct array field. max_capacity is required and specifies the maximum number of struct elements allowed per entity.
The maximum number of struct elements allowed per entity.
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 consistency level applied to the collection described by this setup. It determines the consistency guarantee used when the collection is queried.
Additional Collection properties, given as key-value pairs.
A Collection setup that refers to an existing external Collection, identified by the required collectionName.
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. externalSpec is optional; for a milvus:// source, omitting it defaults format to milvus-table.
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 schema 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 field can be null. If set to true, the field can contain null values.
The default value of the field. This is required if the current field is of the VarChar 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, Zilliz Cloud 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 name of the corresponding column in the external source. Required when creating an external collection.
A list of functions.
A function schema object.
The name of the function to create.
The description of the function to create.
The type of the function to create.
The names of the input fields for the function to create.
A field name.
The names of the output fields for the function to create.
A field name.
Configuration parameters specific to the current function. Once the function type is set to BM25, no parameter is required. For applicable parameters to functions of TEXTEMBEDDING or RERANK, refer to Embedding Functions and Reranking Functions
The external data source identifier. On Zilliz Cloud, externalSource accepts two schemes: volume://<volume_name>/<path> and milvus://<instance_id>/<db_name>/<collection_name>. The milvus:// scheme points to a collection on another cluster compatible with Milvus v3.0.x in the same project and region. The scheme must be lowercase, all three segments are required (including default as the database name), and a single trailing slash is tolerated. Required when creating an external collection.
A JSON-encoded string describing the connection parameters for the external source. The format key accepts parquet, vortex, lance-table, iceberg-table, and milvus-table. Optional when creating an external collection; for a milvus:// source, omitting it defaults format to milvus-table.
A list of struct array fields.
A struct array field that groups multiple sub-fields.
The name of the struct array field.
A description of the struct array field.
The sub-fields in the struct array. Each dataType refers to the scalar or vector type of a struct field.
A sub-field definition within a struct array. The dataType refers to the scalar or vector type of each struct field.
The name of the sub-field.
The scalar or vector type of the struct field.
Parameters for the element type, such as max_length for VarChar or dim for vector types.
Parameters of the struct array field. max_capacity is required and specifies the maximum number of struct elements allowed per entity.
The maximum number of struct elements allowed per entity.
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 consistency level applied to the collection described by this setup. It determines the consistency guarantee used when the collection is queried.
Additional properties to apply to the Collection.
export TOKEN="db_admin:xxxxxxxxxxxxx"
curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Request-Timeout: 5" \
--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: 5" \
--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"
}
}'
Returns a collection object.
A generic response envelope returned by operations that carry no operation-specific result data. It still includes a data object.
Response code.
The response payload object. Its contents depend on the operation that returns it.
Returns an error message.
Response code.
Error message.
{
"code": 0,
"data": {}
}