Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix search iter v2 limit compatibility #2531

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading