From a38a5025d6ce3b7314c9331b70261cea3f1d2d25 Mon Sep 17 00:00:00 2001 From: MrPresent-Han <116052805+MrPresent-Han@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:34:38 +0800 Subject: [PATCH] set reduce_stop_for_best for iterator by default(#1830) (#1832) Signed-off-by: MrPresent-Han --- pymilvus/orm/constants.py | 2 +- pymilvus/orm/iterator.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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")