< Docs
  • Node
    • Vector


This operation inserts or updates data in a specific collection.

upsert(data): Promise<MutationResult>

Request Syntax

   collection_name: string,
   data: RowData[],
   hash_keys: Number[],
   partition_name: string,
   timeout: number


  • collection_name (str) -


    The name of an existing collection.

  • data (RowData[]) -

    The data to insert into the current collection.

    The data to insert should be a dictionary that matches the schema of the current collection or a list of such dictionaries.

    The following code assumes that the schema of the current collection has two fields named id and vector. The former is the primary field and the latter is a field to hold 5-dimensional vector embeddings.

    // A dictionary, or
        'id': 0,
        'vector': [
    // A list of dictionaries
    data = [
            'id': 1,
            'vector': [
            'id': 2,
            'vector': [
  • timeout (number)

    The timeout duration for this operation.

    Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.

  • partition_name (string) -

    The name of a partition in the current collection.

    If specified, the data is to be inserted into the specified partition.

RETURNS Promise<MutationResult>

This method returns a promise that resolves to a MutationResult object.

    IDs: NumberArrayId | StringArrayId,
    acknowledged: boolean,
    delete_cnt: string,
    err_index: list[number],
    insert_cnt: string,
    status: object,
    succ_index: list[number],
    timestamp: string,
    upsert_cnt: string


  • IDs (list[string] | list[number]) -

    A list of the IDs of the upserted entities.

  • acknowledged (list[string] | list[number]) -

    A boolean value indicating whether the upsert operation of the entity is successful.

  • delete_cnt (string) -

    The deleted entities

  • err_index (list[number]) -

    The number of entities involved in the upsert operation that fails to be indexed.

  • insert_cnt (string) -

    The new entities that are inserted.

  • succ_index (list[number]) -

    The number of entities involved in the upsert operation that have been successfully indexed.

  • timestamp (string) -

    The timestamp indicating the time when the upsert operation occurs.

  • upsert_cnt (string) -

    The entities that have been updated.

  • stats (object) -

    • key (string) -

      The property of the upserted data.

    • value (string | number) -

      The value of the property.

  • status (object) -

    • code (number) -

      A code that indicates the operation result. It remains 0 if this operation succeeds.

    • error_code (string | number) -

      An error code that indicates an occurred error. It remains Success if this operation succeeds.

    • reason (string) -

      The reason that indicates the reason for the reported error. It remains an empty string if this operation succeeds.