From 94a89ccef1f2d3042d5f6bae31139fd91fe880ee Mon Sep 17 00:00:00 2001 From: groot Date: Wed, 30 Oct 2024 10:22:17 +0800 Subject: [PATCH] Fix a compatible bug for Gson 2.11.0+ (#1156) Signed-off-by: yhmo --- examples/main/java/io/milvus/v2/HybridSearchExample.java | 4 ++-- src/main/java/io/milvus/common/utils/JsonUtils.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/main/java/io/milvus/v2/HybridSearchExample.java b/examples/main/java/io/milvus/v2/HybridSearchExample.java index fd1439ccd..7fc62f5e1 100644 --- a/examples/main/java/io/milvus/v2/HybridSearchExample.java +++ b/examples/main/java/io/milvus/v2/HybridSearchExample.java @@ -38,7 +38,7 @@ import io.milvus.v2.service.vector.request.data.BinaryVec; import io.milvus.v2.service.vector.request.data.FloatVec; import io.milvus.v2.service.vector.request.data.SparseFloatVec; -import io.milvus.v2.service.vector.request.ranker.RRFRanker; +import io.milvus.v2.service.vector.request.ranker.WeightedRanker; import io.milvus.v2.service.vector.response.QueryResp; import io.milvus.v2.service.vector.response.SearchResp; @@ -213,7 +213,7 @@ private void hybridSearch() { HybridSearchReq hybridSearchReq = HybridSearchReq.builder() .collectionName(COLLECTION_NAME) .searchRequests(searchRequests) - .ranker(new RRFRanker(2)) + .ranker(new WeightedRanker(Arrays.asList(0.2f, 0.5f, 0.6f))) .topK(5) .consistencyLevel(ConsistencyLevel.BOUNDED) .build(); diff --git a/src/main/java/io/milvus/common/utils/JsonUtils.java b/src/main/java/io/milvus/common/utils/JsonUtils.java index 824f454f7..afe9f0ffa 100644 --- a/src/main/java/io/milvus/common/utils/JsonUtils.java +++ b/src/main/java/io/milvus/common/utils/JsonUtils.java @@ -67,6 +67,6 @@ public static String toJson(JsonElement jsonElement) { } public static JsonElement toJsonTree(T obj) { - return GSON_INSTANCE.toJsonTree(obj, new TypeToken() {}.getType()); + return GSON_INSTANCE.toJsonTree(obj); } }