From e3988936b188bdc846f92f013bc320904074e47f Mon Sep 17 00:00:00 2001 From: smellthemoon <64083300+smellthemoon@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:26:45 +0800 Subject: [PATCH] enhance: simplify the structure of search_params (#2507) Signed-off-by: lixinguo Co-authored-by: lixinguo --- pymilvus/client/prepare.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pymilvus/client/prepare.py b/pymilvus/client/prepare.py index 921ed8257..cebcb27ea 100644 --- a/pymilvus/client/prepare.py +++ b/pymilvus/client/prepare.py @@ -943,7 +943,6 @@ def search_requests_with_expr( search_params = { "topk": limit, - "params": params, "round_decimal": round_decimal, "ignore_growing": ignore_growing, } @@ -999,6 +998,20 @@ def search_requests_with_expr( if param.get(HINTS) is not None: search_params[HINTS] = param[HINTS] + # after 2.5.1, all parameters of search_params can be written into one layer + # no more parameters will be written searchParams.params + # to ensure compatibility and milvus can still get a json format parameter + # try to write all the parameters under searchParams into searchParams.Params + for key, value in search_params.items(): + if key in params: + if params[key] != value: + raise ParamError( + message=f"ambiguous parameter: {key}, in search_param: {value}, in search_param.params: {params[key]}" + ) + else: + params[key] = value + search_params["params"] = params + req_params = [ common_types.KeyValuePair(key=str(key), value=utils.dumps(value)) for key, value in search_params.items()