milvus-logo

insert()

This method inserts data into a specified collection.

Invocation

new milvusClient(MILUVS_ADDRESS).dataManager.insert(InsertReq);

Parameters

InsertReq

ParameterDescriptionTypeRequired
collection_nameName of the collection to insert data intoStringTrue
partition_name(optional)Name of the partition to insert data intoStringFalse
fields_dataVector data{ [x: string]: any }[]True
hash_keys(optional)The hash value determined by primary keyNumber[]False
timeoutAn optional duration of time in millisecond to allow for the RPC. Default is undefinedNumberFalse

note

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).dataManager.insert({
  collection_name: COLLECTION_NAME,
  fields_data: vectorsData,
});

Return

// insert return
{
  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',
  },
}