Create Collection
This operation creates a collection in a specified cluster.
The base URL for this API is in the following format:
http://localhost:19530
export CLUSTER_ENDPOINT="http://localhost:19530"
The authentication token should be a pair of colon-joined username and password, like username:password
.
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 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 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, MilvusZilliz 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.
Whether to enable text analysis for the specified VARCHAR
field. When set to true
, it instructs Milvus to use a text analyzer, which tokenizes and filters the text content of the field.
Configures the analyzer for text processing, specifically for DataType.VARCHAR
fields.
Pre-configured analyzer type built into Milvus, which can be used out-of-the-box by specifying its name. Possible values: standard
, english
, chinese
.
Defines the tokenizer type. Possible values: standard
(default), whitespace
, jieba
.
Lists filters to refine tokens produced by the tokenizer, with options for built-in filters and custom filters.
Whether to enable keyword matching for the specified VARCHAR
field. When set to true
, Milvus creates an inverted index for the field, allowing for quick and efficient keyword lookups. enable_match
works in conjunction with enable_analyzer
to provide structured keyword-based text search, with enable_analyzer
handling tokenization and enable_match
handling the search operations on these tokens.
The default value for the field, applicable only to scalar fields that are not primary fields.
Whether the field can be null. Defaults to false
.
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](https://milvus.io/docs/metric.md).
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 details, refer to Vector Indexes.
The type of the index to create
The maximum degree of the node. This applies only when index_type is set to HNSW.
The search scope. This applies only when index_type is set to HNSW.
The number of cluster units. This applies only when index_type is set to IVF-related index types.
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 number of shards to create along with the current 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.
export TOKEN="root:Milvus"
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="root:Milvus"
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": {}}