From 2b5a27d7dcbcc8e1550fbe96fc17ec4f9f571a9c Mon Sep 17 00:00:00 2001 From: MrPresent-Han <116052805+MrPresent-Han@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:32:38 +0800 Subject: [PATCH] set reduce_stop_for_best for iterator by default(#1830) (#1831) Signed-off-by: MrPresent-Han --- pymilvus/client/prepare.py | 1 - pymilvus/orm/constants.py | 2 +- pymilvus/orm/iterator.py | 5 +++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index de52fc860..138146011 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -664,7 +664,6 @@ def search_requestV2_with_ranker( round_decimal: int = -1, **kwargs, ) -> milvus_types.SearchRequestV2: - use_default_consistency = ts_utils.construct_guarantee_ts(collection_name, kwargs) rerank_param["limit"] = limit rerank_param["round_decimal"] = round_decimal diff --git a/pymilvus/orm/constants.py b/pymilvus/orm/constants.py index 0b85d1cff..efacc320d 100644 --- a/pymilvus/orm/constants.py +++ b/pymilvus/orm/constants.py @@ -37,7 +37,7 @@ FIELDS = "fields" EF = "ef" IS_PRIMARY = "is_primary" -STOP_REDUCE_FOR_BEST = "stop_reduce_for_best" +REDUCE_STOP_FOR_BEST = "reduce_stop_for_best" DEFAULT_MAX_L2_DISTANCE = 99999999.0 DEFAULT_MIN_IP_DISTANCE = -99999999.0 DEFAULT_MAX_HAMMING_DISTANCE = 99999999.0 diff --git a/pymilvus/orm/iterator.py b/pymilvus/orm/iterator.py index eadaef9c3..4b7675bd4 100644 --- a/pymilvus/orm/iterator.py +++ b/pymilvus/orm/iterator.py @@ -31,6 +31,7 @@ PARAMS, RADIUS, RANGE_FILTER, + REDUCE_STOP_FOR_BEST, UNLIMITED, ) from .schema import CollectionSchema @@ -77,12 +78,16 @@ def __init__( self._kwargs = kwargs self.__check_set_batch_size(batch_size) self._limit = limit + self.__check_set_reduce_stop_for_best() self._returned_count = 0 self.__setup__pk_prop() self.__set_up_expr(expr) self.__seek() self._cache_id_in_use = NO_CACHE_ID + def __check_set_reduce_stop_for_best(self): + self._kwargs[REDUCE_STOP_FOR_BEST] = "True" + def __check_set_batch_size(self, batch_size: int): if batch_size < 0: raise ParamError(message="batch size cannot be less than zero")