Create a DashVector collection by sending a POST request with the vector dimension, distance metric, and optional predefined fields.
Prerequisites
Before you begin, make sure that you have:
A DashVector cluster. See Create a cluster
An API key. See Manage API keys
The latest DashVector SDK. See Install DashVector SDK
Method and URL
POST https://{Endpoint}/v1/collectionsExample
Replace YOUR_API_KEY and YOUR_CLUSTER_ENDPOINT with your actual values before running the request.
# Create a collection named "quickstart" with 4-dimensional vectors,
# the default FLOAT data type, the dotproduct distance metric,
# and three predefined fields: name (STRING), age (INT), weight (FLOAT).
curl -XPOST \
-H 'dashvector-auth-token: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"name": "quickstart",
"dimension": 4,
"metric": "dotproduct",
"fields_schema": {
"name": "STRING",
"age": "INT",
"weight": "FLOAT",
"id": 1234567890
}
}' https://YOUR_CLUSTER_ENDPOINT/v1/collections
# example output:
# {"request_id":"19215409-ea66-4db9-8764-26ce2eb5bb99","code":0,"message":""}Request parameters
Parameter | Location | Type | Required | Description |
{Endpoint} | Path | str | Yes | The cluster endpoint, available on the cluster details page in the console. |
dashvector-auth-token | Header | str | Yes | The API key. |
name | Body | str | Yes | The collection name. |
dimension | Body | int | Yes | The number of vector dimensions. Valid values: (1, 20000]. |
dtype | Body | str | No | The vector data type. Valid values: FLOAT (default), INT. |
metric | Body | str | No | The distance metric. Valid values: euclidean, dotproduct, cosine (default). If set to cosine, dtype must be FLOAT. |
fields_schema | Body | object | No | The predefined fields and their data types. Supported data types: STRING, INT, FLOAT. |
Note
For more information about the advantages of predefining fields during collection creation, see Schema-free.
Response parameters
Parameter | Type | Description | Example |
code | int | The status code. 0 indicates success. For more information, see Status codes. | 0 |
message | str | The response message. | success |
request_id | str | The unique request ID. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |