milvus-logo
LFAI
< Docs
  • Node

createCollection()

This method creates a collection with the specified schema.

Invocation

new milvusClient(MILUVS_ADDRESS).collectionManager.createCollection(
  CreateCollectionReq
);

Parameters

CreateCollectionReq(object)

ParameterDescriptionTypeRequired
collection_nameName of the collection to createStringTrue
fieldsSchema of the collection to createFieldTrue
timeoutAn optional duration of time in millisecond to allow for the RPC. Default is undefinedNumberFalse

Fields(object)

ParameterDescriptionTypeRequired
nameField nameStringTrue
descriptionField descriptionStringTrue
data_typeData type of the field (see the table below)DataTypeTrue
type_paramsVector field parametersObjectFalse
autoIDBoolean value to indicate whether the IDs are automatically generatedBoolFalse
is_primary_keyBoolean value to indicate whether this field is used as the primary keyBoolFalse

DataType

ValueDescription
0None
1Bool
2Int8
3Int16
4Int32
5Int64
10Float
11Double
20String(Not supported yet)
21Varchar
100Binary vector
101Float vector

Example

new milvusClient(MILUVS_ADDRESS).collectionManager.createCollection({
  collection_name: "my_collection",
  fields: [
    {
      name: "vector_01",
      description: "vector field",
      data_type: DataType.FloatVector,
      type_params: {
        dim: "8",
      },
    },
    {
      name: "age",
      data_type: DataType.Int64,
      autoID: true,
      is_primary_key: true,
      description: "",
    },
  ],
});

Return

// create collection return
{ error_code: 'Success', reason: '' }
Feedback

Was this page helpful?