Skip to content

Commit

Permalink
fix: [2.5] fix search iter v2 limit compatibility (#2532)
Browse files Browse the repository at this point in the history
issue: #2530
pr: #2531

Signed-off-by: Patrick Weizhi Xu <[email protected]>
(cherry picked from commit cd30dc3)
  • Loading branch information
PwzXxm authored Dec 31, 2024
1 parent 940af37 commit 088e73b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pymilvus/client/search_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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,
Expand All @@ -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 = {
Expand Down
6 changes: 2 additions & 4 deletions pymilvus/milvus_client/milvus_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {},
Expand Down

0 comments on commit 088e73b

Please sign in to comment.