Skip to main content

Create Collection

Creates a collection in a cluster.


POST
https://${CLUSTER_ENDPOINT}/v1/vector/collections/create

Example

📘Notes

You can use either of the following ways to authorize:

  • An API Key with appropriate permissions.
  • A colon-joined username and password of the target cluster. For example, username:passowrd.

export CLUSTER_ENDPOINT="https://inxx-xxxxxxxxxxxxxxx.api.gcp-us-west1.zillizcloud.com:19530"
export TOKEN="db_admin:xxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v1/vector/collections/create" \

--header "Authorization: Bearer ${TOKEN}" \
--header "accept: application/json" \
--header "content-type: application/json" \
-d '{
"collectionName": "medium_articles",
"dimension": 256,
"metricType": "L2",
"primaryField": "id",
"vectorField": "vector"
}'

Possible response is similar to the following.

{
"code": 200,
"data": {}
}

Request

Parameters

  • No query parameters required

  • No path parameters required

  • No header parameters required

Request Body

{
"collectionName": "string",
"dimension": "integer",
"metricType": "string",
"primaryField": "string",
"vectorField": "string",
"description": "string"
}
ParameterDescription
collectionNamestring
The name of the collection to create.
dimensioninteger
The number of dimensions for the vector field of the collection. For performance-optimized CUs, this value ranges from 1 to 32768. For capacity-optimized and cost-optimized CUs, this value ranges from 32 to 32768.
The value ranges from 1 to 32768.
metricTypestring
The distance metric used for the collection.
The value defaults to L2
primaryFieldstring
The primary key field.
The value defaults to id
vectorFieldstring
The vector field.
The value defaults to vector
descriptionstring
The description of the collection

Response

Returns an empty object.

Response Body

{
"code": "integer",
"data": {}
}
PropertyDescription
codeinteger
Indicates whether the request succeeds.
  • 0: The request succeeds.
  • Others: Some error occurs.
dataobject

Error Response

{
"code": integer,
"message": string
}
PropertyDescription
codeinteger
Indicates whether the request succeeds.
  • 0: The request succeeds.
  • Others: Some error occurs.
messagestring
Indicates the possible reason for the reported error.