milvus-logo
LFAI
< Docs
  • RESTful
    • v1

Create Collection

Creates a collection in a cluster.

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

Example

Create a collection named medium_articles:

export MILVUS_URI="http://localhost:19530"


curl --request POST \
     --url "${MILVUS_URI}/v1/vector/collections/create" \
     --header "accept: application/json" \
     --header "content-type: application/json" \
     -d '{
       "dbName": "default",   
       "collectionName": "medium_articles",
       "dimension": 256,
       "metricType": "L2",
       "primaryField": "id",
       "vectorField": "vector"
      }'

Success response:

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

Request

Parameters

  • No query parameters required

  • No path parameters required

Request Body

{
    "collectionName": "string",
    "dbName": "string",
    "description": "string",
    "dimension": "integer",
    "metricType": "string",
    "primaryField": "string",
    "vectorField": "string"
}
ParameterDescription
dbNamestring
The name of the database.
collectionNamestring(required)
The name of the collection to create.
dimensioninteger(required)
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 Bodies

  • Response body if we process your request successfully
{
    "code": 200,
    "data": {}
}
  • Response body if we failed to process your request
{
    "code": integer,
    "message": string
}

Properties

The properties in the returned response are listed in the following table.

PropertyDescription
codeinteger
Indicates whether the request succeeds.
  • 200: The request succeeds.
  • Others: Some error occurs.
dataobject
A data object.
messagestring
Indicates the possible reason for the reported error.

Possible Errors

Error CodeDescription
800database not found
1800user hasn't authenticate
1801can only accept json format request
1802missing required parameters
1803fail to marshal collection schema
Feedback

Was this page helpful?