瀏覽代碼

Fix a compatible issue of RRFRanker/WeightedRanker (#1522)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 6 天之前
父節點
當前提交
a7796a1d58

+ 10 - 0
sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/RRFRanker.java

@@ -51,6 +51,16 @@ import java.util.Map;
  */
 @SuperBuilder
 public class RRFRanker extends CreateCollectionReq.Function {
+    // This constructor is to compatible with the old client code like:
+    //  new RRFRanker(10)
+    // Now it is deprecated, user should create a RRFRanker by builder style:
+    //  RRFRanker.builder().k(10).build()
+    @Deprecated
+    public RRFRanker(int k) {
+        super(CreateCollectionReq.Function.builder());
+        this.k = k;
+    }
+
     @Builder.Default
     private int k = 60;
 

+ 10 - 0
sdk-core/src/main/java/io/milvus/v2/service/vector/request/ranker/WeightedRanker.java

@@ -55,6 +55,16 @@ import java.util.Map;
  */
 @SuperBuilder
 public class WeightedRanker extends CreateCollectionReq.Function {
+    // This constructor is to compatible with the old client code like:
+    //  new WeightedRanker(weights)
+    // Now it is deprecated, user should create a WeightedRanker by builder style:
+    //  WeightedRanker.builder().weights(weights).build()
+    @Deprecated
+    public WeightedRanker(List<Float> weights) {
+        super(CreateCollectionReq.Function.builder());
+        this.weights = weights;
+    }
+
     @Builder.Default
     private List<Float> weights = new ArrayList<>();