diff --git a/pymilvus/client/grpc_handler.py b/pymilvus/client/grpc_handler.py index 47ad64976..cbb55b627 100644 --- a/pymilvus/client/grpc_handler.py +++ b/pymilvus/client/grpc_handler.py @@ -567,7 +567,12 @@ def delete( ): check_pass_param(collection_name=collection_name) try: - req = Prepare.delete_request(collection_name, partition_name, expression) + req = Prepare.delete_request( + collection_name, + partition_name, + expression, + consistency_level=kwargs.get("consistency_level", 0), + ) future = self._stub.Delete.future(req, timeout=timeout) if kwargs.get("_async", False): diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 5166cbe6d..84c86dcbd 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -13,7 +13,11 @@ from . import blob, entity_helper, ts_utils from .check import check_pass_param, is_legal_collection_properties -from .constants import DEFAULT_CONSISTENCY_LEVEL, GROUP_BY_FIELD, REDUCE_STOP_FOR_BEST +from .constants import ( + DEFAULT_CONSISTENCY_LEVEL, + GROUP_BY_FIELD, + REDUCE_STOP_FOR_BEST, +) from .types import DataType, PlaceholderType, get_consistency_level from .utils import traverse_info, traverse_rows_info @@ -535,7 +539,13 @@ def batch_upsert_param( return cls._parse_batch_request(request, entities, fields_info, location) @classmethod - def delete_request(cls, collection_name: str, partition_name: str, expr: str): + def delete_request( + cls, + collection_name: str, + partition_name: str, + expr: str, + consistency_level: Optional[Union[int, str]], + ): def check_str(instr: str, prefix: str): if instr is None: raise ParamError(message=f"{prefix} cannot be None") @@ -550,7 +560,10 @@ def check_str(instr: str, prefix: str): check_str(expr, "expr") return milvus_types.DeleteRequest( - collection_name=collection_name, partition_name=partition_name, expr=expr + collection_name=collection_name, + partition_name=partition_name, + expr=expr, + consistency_level=get_consistency_level(consistency_level), ) @classmethod diff --git a/pymilvus/orm/collection.py b/pymilvus/orm/collection.py index de8bc3e2f..d152484b2 100644 --- a/pymilvus/orm/collection.py +++ b/pymilvus/orm/collection.py @@ -530,6 +530,16 @@ def delete( timeout (float, optional): an optional duration of time in seconds to allow for the RPCs. If timeout is not set, the client keeps waiting until the server responds or an error occurs. + **kwargs (``dict``): Optional search params + + * *consistency_level* (``str/int``, optional) + Which consistency level to use when searching in the collection. + + Options of consistency level: Strong, Bounded, Eventually, Session, Customized. + + Note: this parameter overwrites the same one specified when creating collection, + if no consistency level was specified, search will use the + consistency level when you create the collection. Returns: MutationResult: