Class Data

Methods

checkCollectionAndPartitionName

  • Parameters

    • data: any

    Returns void

checkCollectionName

  • Parameters

    • data: any

    Returns void

deleteEntities

  • Delete entities in Milvus

    Parameters

    • data: DeleteEntitiesReq
      Property Type Description
      collection_name String Collection name
      partition_name(optional) String Partition name
      expr String Boolean expression used to filter attribute.

    Returns Promise<MutationResult>

    Property Description
    status { error_code: number, reason: string }
    IDs ID array of the successfully deleted data

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.deleteEntities({
       collection_name: COLLECTION_NAME,
       expr: 'id in [1,2,3,4]'
     });
    

flush

  • Milvus temporarily buffers the newly inserted vectors in the cache. Call flush() to persist them to the object storage. It's async function, so it's will take some times to excute.

    Parameters

    • data: FlushReq
      Property Type Description
      collection_names String[] Array of collection names

    Returns Promise<FlushResult>

    Property Description
    status { error_code: number, reason: string }

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.flush({
        collection_names: ['my_collection'],
     });
    

flushSync

  • It's same function as flush. But flushSync is sync function. So you can ensure it's flushed after function return the result.

    Parameters

    • data: FlushReq
      Property Type Description
      collection_names String[] Array of collection names

    Returns Promise<FlushResult>

    Property Description
    status { error_code: number, reason: string }

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.flushSync({
        collection_names: ['my_collection'],
     });
    

insert

  • Insert data into Milvus.

    Parameters

    • data: InsertReq
      Property Type Description
      collection_name String Collection name
      partition_name(optional) String Partition name
      fields_data { [x: string]: any }[] If the field type is binary, the vector data length needs to be dimension / 8
      hash_keys(optional) Number[] The hash value depends on the primarykey value

    Returns Promise<MutationResult>

    Property Description
    status { error_code: number, reason: string }
    succ_index Index array of the successfully inserted data
    err_index Index array of the unsuccessfully inserted data
    IDs ID array of the successfully inserted data

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.insert({
       collection_name: COLLECTION_NAME,
       fields_data: [{
         vector_field: [1,2,2,4],
         scalar_field: 1
       }]
     });
    

query

  • Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3]

    Parameters

    • data: QueryReq
      Property Type Description
      collection_name String Collection name
      expr String Scalar field filter expression
      partitions_names(optional) String[] Array of partition names
      output_fields String[] Vector or scalar field to be returned

    Returns Promise<QueryResults>

    Property Description
    status { error_code: number,reason:string }
    data Data of all fields that you defined in output_fields, {field_name: value}[]

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.query({
       collection_name: 'my_collection',
       expr: "age in [1,2,3,4,5,6,7,8]",
       output_fields: ["age"],
     });
    

search

  • Perform vector similarity search.

    Parameters

    • data: SearchReq
      Property Type Description
      collection_name String Collection name
      partition_names(optional) String[] Array of partition names
      expr(optional) String Scalar field filter expression
      search_params Object anns_field: vector field name
      topk: search result counts
      metric_type
      params: search params
      vectors Number[][] Original vector to search with
      output_fields(optional) String[] Support scalar field
      vector_type enum Binary field -> 100, Float field -> 101
      travel_timestamp number We can get timestamp after insert success. Use this timestamp we can time travel in vector search.

    Returns Promise<SearchResults>

    Property Description
    status { error_code: number, reason: string }
    results {score:number,id:string}[];

    Example

     new milvusClient(MILUVS_ADDRESS).dataManager.search({
      collection_name: COLLECTION_NAME,
      expr: "",
      vectors: [[1, 2, 3, 4]],
      search_params: {
        anns_field: VECTOR_FIELD_NAME,
        topk: "4",
        metric_type: "L2",
        params: JSON.stringify({ nprobe: 1024 }),
      },
      output_fields: ["age", "time"],
      vector_type: 100,
     });