milvus-logo
LFAI
< Docs
  • Node

insert()

This method inserts data into a specified collection.

If the field type is binary, the vector data length needs to be dimension / 8.

Example

const vectorsData = Array.from({ length: 10 }).map(() => ({
  vector_01: Array.from({ length: 4 }).map(() =>
    Math.floor(Math.random() * 10)
  ),
}));

new milvusClient(MILUVS_ADDRESS).insert({
  collection_name: COLLECTION_NAME,
  fields_data: vectorsData,
});

Response

// insert returns
{
  status: { error_code: 'Success', reason: '' },
  succ_index: [
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
    ... 990 more items
  ],
  err_index: [],
  acknowledged: false,
  insert_cnt: '1',
  delete_cnt: '0',
  upsert_cnt: '0',
  timestamp: '434849944099356674',
  IDs: {
    int_id: {
      data: [
        '434848878802250134',
        ...999 more items,
      ],
    },
    id_field: 'int_id',
  },
}

Parameters

ParametersDescriptionType
collection_nameName of the collection to insert data intoString
fields_dataVector data{ [x: string]: any }[]
data node sdk v2.2.12+Vector data, fields_data alias{ [x: string]: any }[]
partition_name?Name of the partition to insert data intoString
timeout?This parameter is used to specify the length of time, in milliseconds, that the RPC (Remote Procedure Call) is allowed to run. If no value is provided, the default is undefined.Number
Feedback

Was this page helpful?