From cd30dc311e98159a6670cedd0fc6bf793669357e Mon Sep 17 00:00:00 2001 From: Patrick Weizhi Xu Date: Mon, 30 Dec 2024 19:35:10 +0800 Subject: [PATCH] fix: fix search iter v2 limit compatibility Signed-off-by: Patrick Weizhi Xu --- pymilvus/client/search_iterator.py | 10 +++++----- pymilvus/milvus_client/milvus_client.py | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pymilvus/client/search_iterator.py b/pymilvus/client/search_iterator.py index f0225a720..cf87a43f8 100644 --- a/pymilvus/client/search_iterator.py +++ b/pymilvus/client/search_iterator.py @@ -14,7 +14,7 @@ ) from pymilvus.exceptions import ExceptionsMessage, ParamError, ServerVersionIncompatibleException from pymilvus.orm.connections import Connections -from pymilvus.orm.constants import MAX_BATCH_SIZE, MILVUS_LIMIT, OFFSET +from pymilvus.orm.constants import MAX_BATCH_SIZE, OFFSET, UNLIMITED from pymilvus.orm.iterator import SearchPage, fall_back_to_latest_session_ts logger = logging.getLogger(__name__) @@ -33,6 +33,7 @@ def __init__( collection_name: str, data: Union[List, utils.SparseMatrixInputType], batch_size: int = 1000, + limit: Optional[int] = UNLIMITED, filter: Optional[str] = None, output_fields: Optional[List[str]] = None, search_params: Optional[Dict] = None, @@ -44,10 +45,9 @@ def __init__( ): self._check_params(batch_size, data, kwargs) - # for compatibility, delete limit from incoming - if MILVUS_LIMIT in kwargs: - self._left_res_cnt = kwargs[MILVUS_LIMIT] - del kwargs[MILVUS_LIMIT] + # for compatibility, support limit, deprecate in future + if limit != UNLIMITED: + self._left_res_cnt = limit self._conn = connection self._params = { diff --git a/pymilvus/milvus_client/milvus_client.py b/pymilvus/milvus_client/milvus_client.py index 6d468e1ef..994b1a8a4 100644 --- a/pymilvus/milvus_client/milvus_client.py +++ b/pymilvus/milvus_client/milvus_client.py @@ -27,7 +27,7 @@ from pymilvus.orm import utility from pymilvus.orm.collection import CollectionSchema from pymilvus.orm.connections import connections -from pymilvus.orm.constants import FIELDS, METRIC_TYPE, MILVUS_LIMIT, TYPE, UNLIMITED +from pymilvus.orm.constants import FIELDS, METRIC_TYPE, TYPE, UNLIMITED from pymilvus.orm.iterator import QueryIterator, SearchIterator from pymilvus.orm.types import DataType @@ -583,14 +583,12 @@ def search_iterator( # compatibility logic, change this when support get version from server try: - # compatibility logic, deprecate limit in the future - if limit is not None and limit != UNLIMITED: - kwargs[MILVUS_LIMIT] = limit return SearchIteratorV2( connection=conn, collection_name=collection_name, data=data, batch_size=batch_size, + limit=limit, filter=filter, output_fields=output_fields, search_params=search_params or {},