Class Collection

Methods

createCollection

  • Create collection in milvus.

    Parameters

    • data: CreateCollectionReq
      Property Type Description
      createCollection string collection name
      description string collection description
      fields FieldType Field data

    Returns Promise<ResStatus>

    Property Description
    error_code error code number
    reason reason

    Example

     new milvusClient(MILUVS_IP).collectionManager.createCollection({
       collection_name: 'my_collection',
       fields: [
         {
           name: "vector_01",
           description: "vector field",
           data_type: DataType.FloatVect,
           type_params: [
             {
               key: "dim",
               value: "128",
             },
           ],
         },
         {
           name: "age",
           data_type: DataType.Int64,
           autoID: true,
           is_primary_key: true,
           description: "",
         },
     ],
     });
    

describeCollection

  • Get collection detail, eg: name, schema.

    Parameters

    • data: DescribeCollectionReq
      Property Type Description
      collection_name string collection name

    Returns Promise<DescribeCollectionResponse>

    Property Description
    status { error_code: number,reason:string }
    schema all fields information in this collection
    collectionID collection id

    Example

     new milvusClient(MILUVS_IP).collectionManager.describeCollection({
       collection_name: 'my_collection',
     });
    

dropCollection

  • Drop collection, it will drop all data in the collection as well.

    Parameters

    • data: DropCollectionReq
      Property Type Description
      collection_name string collection name

    Returns Promise<ResStatus>

    Property Description
    error_code Number
    reason Error reason

    Example

     new milvusClient(MILUVS_IP).collectionManager.dropCollection({
       collection_name: 'my_collection',
     });
    

getCollectionStatistics

  • Get collection statistics information.

    Parameters

    • data: GetCollectionStatisticsReq
      Property Type Description
      collection_name string collection name

    Returns Promise<StatisticsResponse>

    Property Description
    status { error_code: number,reason:string }
    stats [{key: string,value:string}]
    data transform stats to { row_count: 0 }

    Example

     new milvusClient(MILUVS_IP).collectionManager.getCollectionStatistics({
       collection_name: 'my_collection',
     });
    

hasCollection

  • Check if collection exists or not.

    Parameters

    • data: HasCollectionReq
      Property Type Description
      collection_name string collection name

    Returns Promise<BoolResponse>

    Property Description
    status { error_code: number,reason:string }
    value true or false

    Example

     new milvusClient(MILUVS_IP).collectionManager.hasCollection({
        collection_name: 'my_collection',
     });
    

loadCollection

  • Before search, it requires loading collection to cache.

    Parameters

    • data: LoadCollectionReq
      Property Type Description
      collection_name string collection name

    Returns Promise<ResStatus>

    Property Description
    error_code Number
    reason Error reason

    Example

     new milvusClient(MILUVS_IP).collectionManager.loadCollection({
       collection_name: 'my_collection',
     });
    

releaseCollection

  • If you want to reduce your cache usage, you can release some collections. But you can't search in unloaded collections.

    Parameters

    • data: ReleaseLoadCollectionReq
      Property Type Description
      collection_name string collection name

    Returns Promise<ResStatus>

    Property Description
    error_code Number
    reason Error reason

    Example

     new milvusClient(MILUVS_IP).collectionManager.releaseCollection({
       collection_name: 'my_collection',
     });
    

showCollections

  • List all collections with their names and ids.

    Parameters

    • Optional data: ShowCollectionsReq
      Property Type Description
      type enum All -> 0, Loaded -> 1

    Returns Promise<ShowCollectionsResponse>

    Property Description
    status { error_code: number,reason:string }
    collection_names collection name array
    collection_ids collection id array

    Example

     new milvusClient(MILUVS_IP).collectionManager.showCollections();