Skip to content

Commit

Permalink
Support set consistency level on delete request (#312)
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <jiangruiyi@gmail.com>
  • Loading branch information
shanghaikid authored May 29, 2024
1 parent d498080 commit 4d1ede0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions milvus/grpc/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export class Data extends Collection {
* @param {string} data.collection_name - The name of the collection.
* @param {string} [data.partition_name] - The name of the partition (optional).
* @param {string} data.expr - Boolean expression used to filter entities for deletion.
* @param {string} [data.consistency_level] - The consistency level of the new collection. Can be "Strong" (Milvus default), "Session", "Bounded", "Eventually", or "Customized".
* @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
*
* @returns {Promise<MutationResult>} The result of the operation.
Expand Down Expand Up @@ -355,6 +356,7 @@ export class Data extends Collection {
* @param {string} [data.partition_name] - The name of the partition (optional).
* @param {(string[] | number[])} [data.ids] - IDs of the entities to delete.
* @param {string} [data.filter] - Filter expression, takes precedence over ids.
* @param {string} [data.consistency_level] - The consistency level of the new collection. Can be "Strong" (Milvus default), "Session", "Bounded", "Eventually", or "Customized".
* @param {string} [data.expr] - equals to data.filter.
* @param {number} [data.timeout] - Optional duration of time in milliseconds to allow for the RPC. If undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined.
*
Expand Down
19 changes: 13 additions & 6 deletions milvus/types/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,27 @@ export interface InsertReq extends collectionNameReq {
transformers?: InsertTransformers; // provide custom data transformer for specific data type like bf16 or f16 vectors
}

export interface DeleteEntitiesReq extends collectionNameReq {
interface BaseDeleteReq extends collectionNameReq {
partition_name?: string; // partition name
consistency_level?:
| 'Strong'
| 'Session'
| 'Bounded'
| 'Eventually'
| 'Customized'; // consistency level
}

export interface DeleteEntitiesReq extends BaseDeleteReq {
filter?: string; // filter expression
expr?: string; // alias for filter
partition_name?: string; // partition name
}

export interface DeleteByIdsReq extends collectionNameReq {
export interface DeleteByIdsReq extends BaseDeleteReq {
ids: string[] | number[]; // primary key values
partition_name?: string; // partition name
}

export interface DeleteByFilterReq extends collectionNameReq {
export interface DeleteByFilterReq extends BaseDeleteReq {
filter: string; // filter expression
partition_name?: string; // partition name
}

export type DeleteReq = DeleteByIdsReq | DeleteByFilterReq;
Expand Down
1 change: 1 addition & 0 deletions test/grpc/Data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ describe(`Data.API`, () => {
await milvusClient.deleteEntities({
collection_name: COLLECTION_NAME,
expr: 'id in [2,6]',
consistency_level: 'Strong',
});

const res = await milvusClient.query({
Expand Down

0 comments on commit 4d1ede0

Please sign in to comment.