Browse Source

Deprecate topK for search/hybridSearch/iterator, replaced with limit (#1437)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 6 days ago
parent
commit
223ba9f5da
38 changed files with 249 additions and 106 deletions
  1. 1 1
      examples/src/main/java/io/milvus/v1/BinaryVectorExample.java
  2. 1 1
      examples/src/main/java/io/milvus/v1/ClientPoolExample.java
  3. 2 2
      examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java
  4. 1 1
      examples/src/main/java/io/milvus/v1/Float16VectorExample.java
  5. 2 2
      examples/src/main/java/io/milvus/v1/GeneralExample.java
  6. 5 5
      examples/src/main/java/io/milvus/v1/HybridSearchExample.java
  7. 7 3
      examples/src/main/java/io/milvus/v1/IteratorExample.java
  8. 2 2
      examples/src/main/java/io/milvus/v1/SimpleExample.java
  9. 1 1
      examples/src/main/java/io/milvus/v1/SparseVectorExample.java
  10. 1 1
      examples/src/main/java/io/milvus/v2/BinaryVectorExample.java
  11. 1 1
      examples/src/main/java/io/milvus/v2/ClientPoolExample.java
  12. 2 2
      examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java
  13. 1 1
      examples/src/main/java/io/milvus/v2/Float16VectorExample.java
  14. 1 1
      examples/src/main/java/io/milvus/v2/FullTextSearchExample.java
  15. 1 1
      examples/src/main/java/io/milvus/v2/GeneralExample.java
  16. 4 4
      examples/src/main/java/io/milvus/v2/HybridSearchExample.java
  17. 1 1
      examples/src/main/java/io/milvus/v2/Int8VectorExample.java
  18. 2 2
      examples/src/main/java/io/milvus/v2/IteratorExample.java
  19. 2 2
      examples/src/main/java/io/milvus/v2/SimpleExample.java
  20. 1 1
      examples/src/main/java/io/milvus/v2/SparseVectorExample.java
  21. 1 1
      examples/src/main/java/io/milvus/v2/TextMatchExample.java
  22. 1 1
      sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java
  23. 7 7
      sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java
  24. 1 0
      sdk-core/src/main/java/io/milvus/param/Constant.java
  25. 3 3
      sdk-core/src/main/java/io/milvus/param/ParamUtils.java
  26. 9 3
      sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java
  27. 10 3
      sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java
  28. 11 6
      sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java
  29. 9 3
      sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java
  30. 24 1
      sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java
  31. 24 1
      sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java
  32. 23 1
      sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java
  33. 23 1
      sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java
  34. 24 2
      sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java
  35. 7 5
      sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java
  36. 17 17
      sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java
  37. 14 14
      sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java
  38. 2 2
      sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java

+ 1 - 1
examples/src/main/java/io/milvus/v1/BinaryVectorExample.java

@@ -157,7 +157,7 @@ public class BinaryVectorExample {
             R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
             R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
                     .withCollectionName(COLLECTION_NAME)
                     .withCollectionName(COLLECTION_NAME)
                     .withMetricType(MetricType.HAMMING)
                     .withMetricType(MetricType.HAMMING)
-                    .withTopK(3)
+                    .withLimit(3L)
                     .withBinaryVectors(Collections.singletonList(targetVector))
                     .withBinaryVectors(Collections.singletonList(targetVector))
                     .withVectorFieldName(VECTOR_FIELD)
                     .withVectorFieldName(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)

+ 1 - 1
examples/src/main/java/io/milvus/v1/ClientPoolExample.java

@@ -163,7 +163,7 @@ public class ClientPoolExample {
                     R<SearchResults> searchRet = client.search(SearchParam.newBuilder()
                     R<SearchResults> searchRet = client.search(SearchParam.newBuilder()
                             .withCollectionName(CollectionName)
                             .withCollectionName(CollectionName)
                             .withMetricType(MetricType.L2)
                             .withMetricType(MetricType.L2)
-                            .withTopK(10)
+                            .withLimit(10L)
                             .withFloatVectors(Collections.singletonList(CommonUtils.generateFloatVector(DIM)))
                             .withFloatVectors(Collections.singletonList(CommonUtils.generateFloatVector(DIM)))
                             .withVectorFieldName(VectorFieldName)
                             .withVectorFieldName(VectorFieldName)
                             .withParams("{}")
                             .withParams("{}")

+ 2 - 2
examples/src/main/java/io/milvus/v1/ConsistencyLevelExample.java

@@ -137,7 +137,7 @@ public class ConsistencyLevelExample {
                 .withCollectionName(collectionName)
                 .withCollectionName(collectionName)
                 .withVectorFieldName("vector")
                 .withVectorFieldName("vector")
                 .withFloatVectors(Collections.singletonList(CommonUtils.generateFloatVector(VECTOR_DIM)))
                 .withFloatVectors(Collections.singletonList(CommonUtils.generateFloatVector(VECTOR_DIM)))
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
                 .build());
                 .build());
         CommonUtils.handleResponseStatus(searchR);
         CommonUtils.handleResponseStatus(searchR);
@@ -204,7 +204,7 @@ public class ConsistencyLevelExample {
                     .withCollectionName(collectionName)
                     .withCollectionName(collectionName)
                     .withVectorFieldName("vector")
                     .withVectorFieldName("vector")
                     .withFloatVectors(Collections.singletonList(vector))
                     .withFloatVectors(Collections.singletonList(vector))
-                    .withTopK(1)
+                    .withLimit(1L)
                     .withMetricType(MetricType.L2)
                     .withMetricType(MetricType.L2)
                     .build());
                     .build());
             pool.returnClient(clientName2, client2); // don't forget to return the client to pool
             pool.returnClient(clientName2, client2); // don't forget to return the client to pool

+ 1 - 1
examples/src/main/java/io/milvus/v1/Float16VectorExample.java

@@ -184,7 +184,7 @@ public class Float16VectorExample {
             SearchParam.Builder builder = SearchParam.newBuilder()
             SearchParam.Builder builder = SearchParam.newBuilder()
                     .withCollectionName(COLLECTION_NAME)
                     .withCollectionName(COLLECTION_NAME)
                     .withMetricType(MetricType.L2)
                     .withMetricType(MetricType.L2)
-                    .withTopK(3)
+                    .withLimit(3L)
                     .withVectorFieldName(VECTOR_FIELD)
                     .withVectorFieldName(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)
                     .withParams("{\"nprobe\":32}");
                     .withParams("{\"nprobe\":32}");

+ 2 - 2
examples/src/main/java/io/milvus/v1/GeneralExample.java

@@ -64,7 +64,7 @@ public class GeneralExample {
     private static final IndexType INDEX_TYPE = IndexType.IVF_FLAT;
     private static final IndexType INDEX_TYPE = IndexType.IVF_FLAT;
     private static final String INDEX_PARAM = "{\"nlist\":128}";
     private static final String INDEX_PARAM = "{\"nlist\":128}";
 
 
-    private static final Integer SEARCH_K = 5;
+    private static final Long SEARCH_K = 5L;
     private static final String SEARCH_PARAM = "{\"nprobe\":10}";
     private static final String SEARCH_PARAM = "{\"nprobe\":10}";
     
     
 
 
@@ -331,7 +331,7 @@ public class GeneralExample {
                 .withCollectionName(COLLECTION_NAME)
                 .withCollectionName(COLLECTION_NAME)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
                 .withOutFields(outFields)
                 .withOutFields(outFields)
-                .withTopK(SEARCH_K)
+                .withLimit(SEARCH_K)
                 .withFloatVectors(vectors)
                 .withFloatVectors(vectors)
                 .withVectorFieldName(VECTOR_FIELD)
                 .withVectorFieldName(VECTOR_FIELD)
                 .withExpr(expr)
                 .withExpr(expr)

+ 5 - 5
examples/src/main/java/io/milvus/v1/HybridSearchExample.java

@@ -226,14 +226,14 @@ public class HybridSearchExample {
                 .withFloatVectors(CommonUtils.generateFloatVectors(FLOAT_VECTOR_DIM, NQ))
                 .withFloatVectors(CommonUtils.generateFloatVectors(FLOAT_VECTOR_DIM, NQ))
                 .withMetricType(FLOAT_VECTOR_METRIC)
                 .withMetricType(FLOAT_VECTOR_METRIC)
                 .withParams("{\"nprobe\": 32}")
                 .withParams("{\"nprobe\": 32}")
-                .withTopK(10)
+                .withLimit(10L)
                 .build();
                 .build();
 
 
         AnnSearchParam req2 = AnnSearchParam.newBuilder()
         AnnSearchParam req2 = AnnSearchParam.newBuilder()
                 .withVectorFieldName(BINARY_VECTOR_FIELD)
                 .withVectorFieldName(BINARY_VECTOR_FIELD)
                 .withBinaryVectors(CommonUtils.generateBinaryVectors(BINARY_VECTOR_DIM, NQ))
                 .withBinaryVectors(CommonUtils.generateBinaryVectors(BINARY_VECTOR_DIM, NQ))
                 .withMetricType(BINARY_VECTOR_METRIC)
                 .withMetricType(BINARY_VECTOR_METRIC)
-                .withTopK(15)
+                .withLimit(15L)
                 .build();
                 .build();
 
 
         AnnSearchParam req3 = AnnSearchParam.newBuilder()
         AnnSearchParam req3 = AnnSearchParam.newBuilder()
@@ -241,7 +241,7 @@ public class HybridSearchExample {
                 .withFloat16Vectors(CommonUtils.generateFloat16Vectors(FLOAT16_VECTOR_DIM, NQ, false))
                 .withFloat16Vectors(CommonUtils.generateFloat16Vectors(FLOAT16_VECTOR_DIM, NQ, false))
                 .withMetricType(FLOAT16_VECTOR_METRIC)
                 .withMetricType(FLOAT16_VECTOR_METRIC)
                 .withParams("{\"ef\":64}")
                 .withParams("{\"ef\":64}")
-                .withTopK(20)
+                .withLimit(20L)
                 .build();
                 .build();
 
 
         AnnSearchParam req4 = AnnSearchParam.newBuilder()
         AnnSearchParam req4 = AnnSearchParam.newBuilder()
@@ -249,7 +249,7 @@ public class HybridSearchExample {
                 .withSparseFloatVectors(CommonUtils.generateSparseVectors(NQ))
                 .withSparseFloatVectors(CommonUtils.generateSparseVectors(NQ))
                 .withMetricType(SPARSE_VECTOR_METRIC)
                 .withMetricType(SPARSE_VECTOR_METRIC)
                 .withParams("{\"drop_ratio_search\":0.2}")
                 .withParams("{\"drop_ratio_search\":0.2}")
-                .withTopK(20)
+                .withLimit(20L)
                 .build();
                 .build();
 
 
         HybridSearchParam searchParam = HybridSearchParam.newBuilder()
         HybridSearchParam searchParam = HybridSearchParam.newBuilder()
@@ -262,7 +262,7 @@ public class HybridSearchExample {
                 .addSearchRequest(req2)
                 .addSearchRequest(req2)
                 .addSearchRequest(req3)
                 .addSearchRequest(req3)
                 .addSearchRequest(req4)
                 .addSearchRequest(req4)
-                .withTopK(5)
+                .withLimit(5L)
                 .withConsistencyLevel(ConsistencyLevelEnum.STRONG)
                 .withConsistencyLevel(ConsistencyLevelEnum.STRONG)
                 .withRanker(RRFRanker.newBuilder()
                 .withRanker(RRFRanker.newBuilder()
                         .withK(2)
                         .withK(2)

+ 7 - 3
examples/src/main/java/io/milvus/v1/IteratorExample.java

@@ -239,16 +239,18 @@ public class IteratorExample {
 
 
     private void iterateQueryResult(QueryIterator queryIterator) {
     private void iterateQueryResult(QueryIterator queryIterator) {
         int pageIdx = 0;
         int pageIdx = 0;
+        int iterateCount = 0;
         while (true) {
         while (true) {
             List<QueryResultsWrapper.RowRecord> res = queryIterator.next();
             List<QueryResultsWrapper.RowRecord> res = queryIterator.next();
             if (res.isEmpty()) {
             if (res.isEmpty()) {
-                System.out.println("query iteration finished, close");
+                System.out.printf("query iteration finished, %d rows iterated, iterator close\n", iterateCount);
                 queryIterator.close();
                 queryIterator.close();
                 break;
                 break;
             }
             }
 
 
             for (QueryResultsWrapper.RowRecord re : res) {
             for (QueryResultsWrapper.RowRecord re : res) {
                 System.out.println(re);
                 System.out.println(re);
+                iterateCount++;
             }
             }
             pageIdx++;
             pageIdx++;
             System.out.printf("page%s-------------------------%n", pageIdx);
             System.out.printf("page%s-------------------------%n", pageIdx);
@@ -257,16 +259,18 @@ public class IteratorExample {
 
 
     private void iterateSearchResult(SearchIterator searchIterator) {
     private void iterateSearchResult(SearchIterator searchIterator) {
         int pageIdx = 0;
         int pageIdx = 0;
+        int iterateCount = 0;
         while (true) {
         while (true) {
             List<QueryResultsWrapper.RowRecord> res = searchIterator.next();
             List<QueryResultsWrapper.RowRecord> res = searchIterator.next();
             if (res.isEmpty()) {
             if (res.isEmpty()) {
-                System.out.println("search iteration finished, close");
+                System.out.printf("search iteration finished, %d rows iterated, iterator close\n", iterateCount);
                 searchIterator.close();
                 searchIterator.close();
                 break;
                 break;
             }
             }
 
 
             for (QueryResultsWrapper.RowRecord re : res) {
             for (QueryResultsWrapper.RowRecord re : res) {
                 System.out.println(re);
                 System.out.println(re);
+                iterateCount++;
             }
             }
             pageIdx++;
             pageIdx++;
             System.out.printf("page%s-------------------------%n", pageIdx);
             System.out.printf("page%s-------------------------%n", pageIdx);
@@ -302,7 +306,7 @@ public class IteratorExample {
                 .withMetricType(MetricType.L2);
                 .withMetricType(MetricType.L2);
 
 
         if (topK != null) {
         if (topK != null) {
-            searchIteratorParamBuilder.withTopK(topK);
+            searchIteratorParamBuilder.withLimit(topK.longValue());
         }
         }
 
 
         R<SearchIterator> response = milvusClient.searchIterator(searchIteratorParamBuilder.build());
         R<SearchIterator> response = milvusClient.searchIterator(searchIteratorParamBuilder.build());

+ 2 - 2
examples/src/main/java/io/milvus/v1/SimpleExample.java

@@ -144,8 +144,8 @@ public class SimpleExample {
         R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
         R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
                 .withCollectionName(COLLECTION_NAME)
                 .withCollectionName(COLLECTION_NAME)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
-                .withTopK(5)
-                .withFloatVectors(Arrays.asList(vector))
+                .withLimit(5L)
+                .withFloatVectors(Collections.singletonList(vector))
                 .withVectorFieldName(VECTOR_FIELD)
                 .withVectorFieldName(VECTOR_FIELD)
                 .withParams("{}")
                 .withParams("{}")
                 .addOutField(VECTOR_FIELD)
                 .addOutField(VECTOR_FIELD)

+ 1 - 1
examples/src/main/java/io/milvus/v1/SparseVectorExample.java

@@ -153,7 +153,7 @@ public class SparseVectorExample {
             R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
             R<SearchResults> searchRet = milvusClient.search(SearchParam.newBuilder()
                     .withCollectionName(COLLECTION_NAME)
                     .withCollectionName(COLLECTION_NAME)
                     .withMetricType(MetricType.IP)
                     .withMetricType(MetricType.IP)
-                    .withTopK(3)
+                    .withLimit(3L)
                     .withSparseFloatVectors(Collections.singletonList(targetVector))
                     .withSparseFloatVectors(Collections.singletonList(targetVector))
                     .withVectorFieldName(VECTOR_FIELD)
                     .withVectorFieldName(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)
                     .addOutField(VECTOR_FIELD)

+ 1 - 1
examples/src/main/java/io/milvus/v2/BinaryVectorExample.java

@@ -136,7 +136,7 @@ public class BinaryVectorExample {
                     .annsField(VECTOR_FIELD)
                     .annsField(VECTOR_FIELD)
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
                     .searchParams(params)
                     .searchParams(params)
-                    .topK(3)
+                    .limit(3)
                     .build());
                     .build());
 
 
             // The search() allows multiple target vectors to search in a batch.
             // The search() allows multiple target vectors to search in a batch.

+ 1 - 1
examples/src/main/java/io/milvus/v2/ClientPoolExample.java

@@ -132,7 +132,7 @@ public class ClientPoolExample {
                             .collectionName(CollectionName)
                             .collectionName(CollectionName)
                             .consistencyLevel(ConsistencyLevel.EVENTUALLY)
                             .consistencyLevel(ConsistencyLevel.EVENTUALLY)
                             .annsField(VectorFieldName)
                             .annsField(VectorFieldName)
-                            .topK(10)
+                            .limit(10)
                             .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(DIM))))
                             .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(DIM))))
                             .build());
                             .build());
                     System.out.println("A search request completed");
                     System.out.println("A search request completed");

+ 2 - 2
examples/src/main/java/io/milvus/v2/ConsistencyLevelExample.java

@@ -100,7 +100,7 @@ public class ConsistencyLevelExample {
         SearchResp searchR = client.search(SearchReq.builder()
         SearchResp searchR = client.search(SearchReq.builder()
                 .collectionName(collectionName)
                 .collectionName(collectionName)
                 .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
-                .topK(topK)
+                .limit(topK)
                 .build());
                 .build());
         List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();
         List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();
         return searchResults.get(0);
         return searchResults.get(0);
@@ -162,7 +162,7 @@ public class ConsistencyLevelExample {
             SearchResp searchR = client2.search(SearchReq.builder()
             SearchResp searchR = client2.search(SearchReq.builder()
                     .collectionName(collectionName)
                     .collectionName(collectionName)
                     .data(Collections.singletonList(new FloatVec(vector)))
                     .data(Collections.singletonList(new FloatVec(vector)))
-                    .topK(1)
+                    .limit(1)
                     .build());
                     .build());
             pool.returnClient(clientName2, client2); // don't forget to return the client to pool
             pool.returnClient(clientName2, client2); // don't forget to return the client to pool
             List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();
             List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();

+ 1 - 1
examples/src/main/java/io/milvus/v2/Float16VectorExample.java

@@ -139,7 +139,7 @@ public class Float16VectorExample {
                 .collectionName(COLLECTION_NAME)
                 .collectionName(COLLECTION_NAME)
                 .data(targetVectors)
                 .data(targetVectors)
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
-                .topK(topK)
+                .limit(topK)
                 .outputFields(Collections.singletonList(vectorFieldName))
                 .outputFields(Collections.singletonList(vectorFieldName))
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .build());
                 .build());

+ 1 - 1
examples/src/main/java/io/milvus/v2/FullTextSearchExample.java

@@ -31,7 +31,7 @@ public class FullTextSearchExample {
         SearchResp searchResp = client.search(SearchReq.builder()
         SearchResp searchResp = client.search(SearchReq.builder()
                 .collectionName(COLLECTION_NAME)
                 .collectionName(COLLECTION_NAME)
                 .data(Collections.singletonList(new EmbeddedText(text)))
                 .data(Collections.singletonList(new EmbeddedText(text)))
-                .topK(3)
+                .limit(3)
                 .outputFields(Collections.singletonList("text"))
                 .outputFields(Collections.singletonList("text"))
                 .build());
                 .build());
         System.out.println("\nSearch by text: " + text);
         System.out.println("\nSearch by text: " + text);

+ 1 - 1
examples/src/main/java/io/milvus/v2/GeneralExample.java

@@ -187,7 +187,7 @@ public class GeneralExample {
         params.put("nprobe",10);
         params.put("nprobe",10);
         SearchResp resp = client.search(SearchReq.builder()
         SearchResp resp = client.search(SearchReq.builder()
                 .collectionName(COLLECTION_NAME)
                 .collectionName(COLLECTION_NAME)
-                .topK(SEARCH_K)
+                .limit(SEARCH_K)
                 .data(vectors)
                 .data(vectors)
                 .annsField(VECTOR_FIELD)
                 .annsField(VECTOR_FIELD)
                 .filter(filter)
                 .filter(filter)

+ 4 - 4
examples/src/main/java/io/milvus/v2/HybridSearchExample.java

@@ -197,24 +197,24 @@ public class HybridSearchExample {
                 .vectorFieldName("float_vector")
                 .vectorFieldName("float_vector")
                 .vectors(floatVectors)
                 .vectors(floatVectors)
                 .params("{\"nprobe\": 10}")
                 .params("{\"nprobe\": 10}")
-                .topK(10)
+                .limit(10)
                 .build());
                 .build());
         searchRequests.add(AnnSearchReq.builder()
         searchRequests.add(AnnSearchReq.builder()
                 .vectorFieldName("binary_vector")
                 .vectorFieldName("binary_vector")
                 .vectors(binaryVectors)
                 .vectors(binaryVectors)
-                .topK(50)
+                .limit(50)
                 .build());
                 .build());
         searchRequests.add(AnnSearchReq.builder()
         searchRequests.add(AnnSearchReq.builder()
                 .vectorFieldName("sparse_vector")
                 .vectorFieldName("sparse_vector")
                 .vectors(sparseVectors)
                 .vectors(sparseVectors)
-                .topK(100)
+                .limit(100)
                 .build());
                 .build());
 
 
         HybridSearchReq hybridSearchReq = HybridSearchReq.builder()
         HybridSearchReq hybridSearchReq = HybridSearchReq.builder()
                 .collectionName(COLLECTION_NAME)
                 .collectionName(COLLECTION_NAME)
                 .searchRequests(searchRequests)
                 .searchRequests(searchRequests)
                 .ranker(new WeightedRanker(Arrays.asList(0.2f, 0.5f, 0.6f)))
                 .ranker(new WeightedRanker(Arrays.asList(0.2f, 0.5f, 0.6f)))
-                .topK(5)
+                .limit(5)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .build();
                 .build();
         SearchResp searchResp = client.hybridSearch(hybridSearchReq);
         SearchResp searchResp = client.hybridSearch(hybridSearchReq);

+ 1 - 1
examples/src/main/java/io/milvus/v2/Int8VectorExample.java

@@ -127,7 +127,7 @@ public class Int8VectorExample {
                     .data(Collections.singletonList(new Int8Vec(targetVector)))
                     .data(Collections.singletonList(new Int8Vec(targetVector)))
                     .annsField(VECTOR_FIELD)
                     .annsField(VECTOR_FIELD)
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
-                    .topK(3)
+                    .limit(3)
                     .build());
                     .build());
 
 
             // The search() allows multiple target vectors to search in a batch.
             // The search() allows multiple target vectors to search in a batch.

+ 2 - 2
examples/src/main/java/io/milvus/v2/IteratorExample.java

@@ -171,7 +171,7 @@ public class IteratorExample {
                 .vectors(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .vectors(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .expr(expr)
                 .expr(expr)
                 .params(StringUtils.isEmpty(params) ? "{}" : params)
                 .params(StringUtils.isEmpty(params) ? "{}" : params)
-                .topK(topK)
+                .limit(topK)
                 .metricType(IndexParam.MetricType.L2)
                 .metricType(IndexParam.MetricType.L2)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .build());
                 .build());
@@ -210,7 +210,7 @@ public class IteratorExample {
                 .vectors(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .vectors(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .filter(filter)
                 .filter(filter)
                 .searchParams(params==null ? new HashMap<>() : params)
                 .searchParams(params==null ? new HashMap<>() : params)
-                .topK(topK)
+                .limit(topK)
                 .metricType(IndexParam.MetricType.L2)
                 .metricType(IndexParam.MetricType.L2)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .externalFilterFunc(externalFilterFunc)
                 .externalFilterFunc(externalFilterFunc)

+ 2 - 2
examples/src/main/java/io/milvus/v2/SimpleExample.java

@@ -93,7 +93,7 @@ public class SimpleExample {
                 .collectionName(collectionName)
                 .collectionName(collectionName)
                 .data(Collections.singletonList(new FloatVec(new float[]{1.0f, 1.0f, 1.0f, 1.0f})))
                 .data(Collections.singletonList(new FloatVec(new float[]{1.0f, 1.0f, 1.0f, 1.0f})))
                 .filter("id < 100")
                 .filter("id < 100")
-                .topK(10)
+                .limit(10)
                 .outputFields(Collections.singletonList("*"))
                 .outputFields(Collections.singletonList("*"))
                 .build());
                 .build());
         List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();
         List<List<SearchResp.SearchResult>> searchResults = searchR.getSearchResults();
@@ -119,7 +119,7 @@ public class SimpleExample {
             SearchReq request = SearchReq.builder()
             SearchReq request = SearchReq.builder()
                     .collectionName(collectionName)
                     .collectionName(collectionName)
                     .data(Collections.singletonList(new FloatVec(new float[]{1.0f, 1.0f, 1.0f, 1.0f})))
                     .data(Collections.singletonList(new FloatVec(new float[]{1.0f, 1.0f, 1.0f, 1.0f})))
-                    .topK(10)
+                    .limit(10)
                     .filter(key)
                     .filter(key)
                     .filterTemplateValues(value)
                     .filterTemplateValues(value)
                     .outputFields(Collections.singletonList("*"))
                     .outputFields(Collections.singletonList("*"))

+ 1 - 1
examples/src/main/java/io/milvus/v2/SparseVectorExample.java

@@ -128,7 +128,7 @@ public class SparseVectorExample {
                     .annsField(VECTOR_FIELD)
                     .annsField(VECTOR_FIELD)
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
                     .outputFields(Collections.singletonList(VECTOR_FIELD))
                     .searchParams(params)
                     .searchParams(params)
-                    .topK(3)
+                    .limit(3)
                     .build());
                     .build());
 
 
             // The search() allows multiple target vectors to search in a batch.
             // The search() allows multiple target vectors to search in a batch.

+ 1 - 1
examples/src/main/java/io/milvus/v2/TextMatchExample.java

@@ -47,7 +47,7 @@ public class TextMatchExample {
                 .collectionName(COLLECTION_NAME)
                 .collectionName(COLLECTION_NAME)
                 .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .data(Collections.singletonList(new FloatVec(CommonUtils.generateFloatVector(VECTOR_DIM))))
                 .filter(filter)
                 .filter(filter)
-                .topK(10)
+                .limit(10)
                 .outputFields(Collections.singletonList("text"))
                 .outputFields(Collections.singletonList("text"))
                 .build());
                 .build());
         System.out.println("\nSearch by filter: " + filter);
         System.out.println("\nSearch by filter: " + filter);

+ 1 - 1
sdk-core/src/main/java/io/milvus/orm/iterator/IteratorAdapterV2.java

@@ -70,7 +70,7 @@ public class IteratorAdapterV2 {
                 .withPartitionNames(searchIteratorReq.getPartitionNames())
                 .withPartitionNames(searchIteratorReq.getPartitionNames())
                 .withVectorFieldName(searchIteratorReq.getVectorFieldName())
                 .withVectorFieldName(searchIteratorReq.getVectorFieldName())
                 .withMetricType(metricType)
                 .withMetricType(metricType)
-                .withTopK(searchIteratorReq.getTopK())
+                .withLimit(searchIteratorReq.getLimit())
                 .withExpr(searchIteratorReq.getExpr())
                 .withExpr(searchIteratorReq.getExpr())
                 .withOutFields(searchIteratorReq.getOutputFields())
                 .withOutFields(searchIteratorReq.getOutputFields())
                 .withRoundDecimal(searchIteratorReq.getRoundDecimal())
                 .withRoundDecimal(searchIteratorReq.getRoundDecimal())

+ 7 - 7
sdk-core/src/main/java/io/milvus/orm/iterator/SearchIterator.java

@@ -64,7 +64,7 @@ public class SearchIterator {
 
 
     private final SearchIteratorParam searchIteratorParam;
     private final SearchIteratorParam searchIteratorParam;
     private final int batchSize;
     private final int batchSize;
-    private final int topK;
+    private final long topK;
     private final String expr;
     private final String expr;
     private final String metricType;
     private final String metricType;
 
 
@@ -127,9 +127,9 @@ public class SearchIterator {
         if (!initSuccess || checkReachedLimit()) {
         if (!initSuccess || checkReachedLimit()) {
             return Lists.newArrayList();
             return Lists.newArrayList();
         }
         }
-        int retLen = batchSize;
+        long retLen = batchSize;
         if (topK != UNLIMITED) {
         if (topK != UNLIMITED) {
-            int leftLen = topK - returnedCount;
+            long leftLen = topK - returnedCount;
             retLen = Math.min(leftLen, retLen);
             retLen = Math.min(leftLen, retLen);
         }
         }
 
 
@@ -387,12 +387,12 @@ public class SearchIterator {
         return true;
         return true;
     }
     }
 
 
-    private boolean isCacheEnough(int count) {
+    private boolean isCacheEnough(long count) {
         List<QueryResultsWrapper.RowRecord> cachedPage = iteratorCache.fetchCache(cacheId);
         List<QueryResultsWrapper.RowRecord> cachedPage = iteratorCache.fetchCache(cacheId);
         return cachedPage != null && cachedPage.size() >= count;
         return cachedPage != null && cachedPage.size() >= count;
     }
     }
 
 
-    private List<QueryResultsWrapper.RowRecord> extractPageFromCache(int count) {
+    private List<QueryResultsWrapper.RowRecord> extractPageFromCache(long count) {
         List<QueryResultsWrapper.RowRecord> cachedPage = iteratorCache.fetchCache(cacheId);
         List<QueryResultsWrapper.RowRecord> cachedPage = iteratorCache.fetchCache(cacheId);
         if (cachedPage == null || cachedPage.size() < count) {
         if (cachedPage == null || cachedPage.size() < count) {
             String msg = String.format("Wrong, try to extract %s result from cache, more than %s there must be sth wrong with code",
             String msg = String.format("Wrong, try to extract %s result from cache, more than %s there must be sth wrong with code",
@@ -400,8 +400,8 @@ public class SearchIterator {
             throw new ParamException(msg);
             throw new ParamException(msg);
         }
         }
 
 
-        List<QueryResultsWrapper.RowRecord> retPageRes = cachedPage.subList(0, count);
-        List<QueryResultsWrapper.RowRecord> leftCachePage = cachedPage.subList(count, cachedPage.size());
+        List<QueryResultsWrapper.RowRecord> retPageRes = cachedPage.subList(0, (int)count);
+        List<QueryResultsWrapper.RowRecord> leftCachePage = cachedPage.subList((int)count, cachedPage.size());
 
 
         iteratorCache.cache(cacheId, leftCachePage);
         iteratorCache.cache(cacheId, leftCachePage);
         return retPageRes;
         return retPageRes;

+ 1 - 0
sdk-core/src/main/java/io/milvus/param/Constant.java

@@ -97,6 +97,7 @@ public class Constant {
     public static final int MAX_BATCH_SIZE = 16384;
     public static final int MAX_BATCH_SIZE = 16384;
     public static final int NO_CACHE_ID = -1;
     public static final int NO_CACHE_ID = -1;
     public static final int UNLIMITED = -1;
     public static final int UNLIMITED = -1;
+    public static final long UNLIMITED_L = -1;
     public static final int DEFAULT_SEARCH_EXTENSION_RATE = 10;
     public static final int DEFAULT_SEARCH_EXTENSION_RATE = 10;
     public static final int MAX_FILTERED_IDS_COUNT_ITERATION = 100000;
     public static final int MAX_FILTERED_IDS_COUNT_ITERATION = 100000;
     public static final int MAX_TRY_TIME = 20;
     public static final int MAX_TRY_TIME = 20;

+ 3 - 3
sdk-core/src/main/java/io/milvus/param/ParamUtils.java

@@ -1049,9 +1049,9 @@ public class ParamUtils {
         // set ranker
         // set ranker
         BaseRanker ranker = requestParam.getRanker();
         BaseRanker ranker = requestParam.getRanker();
         Map<String, String> props = ranker.getProperties();
         Map<String, String> props = ranker.getProperties();
-        props.put(Constant.LIMIT, String.format("%d", requestParam.getTopK()));
-        props.put(Constant.ROUND_DECIMAL, String.format("%d", requestParam.getRoundDecimal()));
-        props.put(Constant.OFFSET, String.format("%d", requestParam.getOffset()));
+        props.put(Constant.LIMIT, String.valueOf(requestParam.getTopK()));
+        props.put(Constant.ROUND_DECIMAL, String.valueOf(requestParam.getRoundDecimal()));
+        props.put(Constant.OFFSET, String.valueOf(requestParam.getOffset()));
         List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
         List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
         if (CollectionUtils.isNotEmpty(propertiesList)) {
         if (CollectionUtils.isNotEmpty(propertiesList)) {
             propertiesList.forEach(builder::addRankParams);
             propertiesList.forEach(builder::addRankParams);

+ 9 - 3
sdk-core/src/main/java/io/milvus/param/dml/AnnSearchParam.java

@@ -40,7 +40,7 @@ public class AnnSearchParam {
 
 
     private final String metricType;
     private final String metricType;
     private final String vectorFieldName;
     private final String vectorFieldName;
-    private final int topK;
+    private final Long topK;
     private final String expr;
     private final String expr;
     private final List<?> vectors;
     private final List<?> vectors;
     private final Long NQ;
     private final Long NQ;
@@ -68,7 +68,7 @@ public class AnnSearchParam {
     public static class Builder {
     public static class Builder {
         private MetricType metricType = MetricType.None;
         private MetricType metricType = MetricType.None;
         private String vectorFieldName;
         private String vectorFieldName;
-        private Integer topK;
+        private Long topK;
         private String expr = "";
         private String expr = "";
         private List<?> vectors;
         private List<?> vectors;
         private Long NQ;
         private Long NQ;
@@ -110,8 +110,14 @@ public class AnnSearchParam {
          * @param topK topK value
          * @param topK topK value
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withTopK(@NonNull Integer topK) {
         public Builder withTopK(@NonNull Integer topK) {
-            this.topK = topK;
+            this.topK = topK.longValue();
+            return this;
+        }
+
+        public Builder withLimit(@NonNull Long limit) {
+            this.topK = limit;
             return this;
             return this;
         }
         }
 
 

+ 10 - 3
sdk-core/src/main/java/io/milvus/param/dml/HybridSearchParam.java

@@ -42,7 +42,7 @@ public class HybridSearchParam {
     private final List<String> partitionNames;
     private final List<String> partitionNames;
     private final List<AnnSearchParam> searchRequests;
     private final List<AnnSearchParam> searchRequests;
     private final BaseRanker ranker;
     private final BaseRanker ranker;
-    private final int topK;
+    private final Long topK;
     private final List<String> outFields;
     private final List<String> outFields;
     private final long offset;
     private final long offset;
     private final int roundDecimal;
     private final int roundDecimal;
@@ -81,7 +81,7 @@ public class HybridSearchParam {
         private final List<String> partitionNames = Lists.newArrayList();
         private final List<String> partitionNames = Lists.newArrayList();
         private final List<AnnSearchParam> searchRequests = Lists.newArrayList();
         private final List<AnnSearchParam> searchRequests = Lists.newArrayList();
         private BaseRanker ranker = null;
         private BaseRanker ranker = null;
-        private Integer topK;
+        private Long topK;
         private final List<String> outFields = Lists.newArrayList();
         private final List<String> outFields = Lists.newArrayList();
         private Long offset = 0L;
         private Long offset = 0L;
         private Integer roundDecimal = -1;
         private Integer roundDecimal = -1;
@@ -174,12 +174,19 @@ public class HybridSearchParam {
 
 
         /**
         /**
          * Sets topK value of ANN search.
          * Sets topK value of ANN search.
+         * withTopK() is deprecated, replaced by withLimit()
          *
          *
          * @param topK topK value
          * @param topK topK value
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withTopK(@NonNull Integer topK) {
         public Builder withTopK(@NonNull Integer topK) {
-            this.topK = topK;
+            this.topK = topK.longValue();
+            return this;
+        }
+
+        public Builder withLimit(@NonNull Long limit) {
+            this.topK = limit;
             return this;
             return this;
         }
         }
 
 

+ 11 - 6
sdk-core/src/main/java/io/milvus/param/dml/SearchIteratorParam.java

@@ -35,8 +35,6 @@ import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.List;
 import java.util.SortedMap;
 import java.util.SortedMap;
 
 
-import static io.milvus.param.Constant.UNLIMITED;
-
 /**
 /**
  * Parameters for <code>searchIterator</code> interface.
  * Parameters for <code>searchIterator</code> interface.
  */
  */
@@ -48,7 +46,7 @@ public class SearchIteratorParam {
     private final List<String> partitionNames;
     private final List<String> partitionNames;
     private final String metricType;
     private final String metricType;
     private final String vectorFieldName;
     private final String vectorFieldName;
-    private final int topK;
+    private final Long topK;
     private final String expr;
     private final String expr;
     private final List<String> outFields;
     private final List<String> outFields;
     private final List<?> vectors;
     private final List<?> vectors;
@@ -102,7 +100,7 @@ public class SearchIteratorParam {
         private final List<String> partitionNames = Lists.newArrayList();
         private final List<String> partitionNames = Lists.newArrayList();
         private MetricType metricType = MetricType.None;
         private MetricType metricType = MetricType.None;
         private String vectorFieldName;
         private String vectorFieldName;
-        private Integer topK = UNLIMITED;
+        private Long topK = Constant.UNLIMITED_L;
         private String expr = "";
         private String expr = "";
         private final List<String> outFields = Lists.newArrayList();
         private final List<String> outFields = Lists.newArrayList();
         private List<?> vectors;
         private List<?> vectors;
@@ -207,12 +205,19 @@ public class SearchIteratorParam {
 
 
         /**
         /**
          * Sets topK value of ANN search.
          * Sets topK value of ANN search.
+         * withTopK() is deprecated, replaced by withLimit()
          *
          *
          * @param topK topK value
          * @param topK topK value
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withTopK(@NonNull Integer topK) {
         public Builder withTopK(@NonNull Integer topK) {
-            this.topK = topK;
+            this.topK = topK.longValue();
+            return this;
+        }
+
+        public Builder withLimit(@NonNull Long limit) {
+            this.topK = limit;
             return this;
             return this;
         }
         }
 
 
@@ -406,7 +411,7 @@ public class SearchIteratorParam {
             ParamUtils.CheckNullEmptyString(collectionName, "Collection name");
             ParamUtils.CheckNullEmptyString(collectionName, "Collection name");
             ParamUtils.CheckNullEmptyString(vectorFieldName, "Target field name");
             ParamUtils.CheckNullEmptyString(vectorFieldName, "Target field name");
 
 
-            if (topK != UNLIMITED && topK <= 0) {
+            if (topK != Constant.UNLIMITED_L && topK <= 0) {
                 throw new ParamException("TopK value is illegal");
                 throw new ParamException("TopK value is illegal");
             }
             }
 
 

+ 9 - 3
sdk-core/src/main/java/io/milvus/param/dml/SearchParam.java

@@ -43,7 +43,7 @@ public class SearchParam {
     private final List<String> partitionNames;
     private final List<String> partitionNames;
     private final String metricType;
     private final String metricType;
     private final String vectorFieldName;
     private final String vectorFieldName;
-    private final int topK;
+    private final Long topK;
     private final String expr;
     private final String expr;
     private final List<String> outFields;
     private final List<String> outFields;
     private final List<?> vectors;
     private final List<?> vectors;
@@ -97,7 +97,7 @@ public class SearchParam {
         private final List<String> partitionNames = Lists.newArrayList();
         private final List<String> partitionNames = Lists.newArrayList();
         private MetricType metricType = MetricType.None;
         private MetricType metricType = MetricType.None;
         private String vectorFieldName;
         private String vectorFieldName;
-        private Integer topK;
+        private Long topK;
         private String expr = "";
         private String expr = "";
         private final List<String> outFields = Lists.newArrayList();
         private final List<String> outFields = Lists.newArrayList();
         private List<?> vectors;
         private List<?> vectors;
@@ -202,12 +202,18 @@ public class SearchParam {
 
 
         /**
         /**
          * Sets topK value of ANN search.
          * Sets topK value of ANN search.
+         * withTopK() is deprecated, replaced by withLimit()
          *
          *
          * @param topK topK value
          * @param topK topK value
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withTopK(@NonNull Integer topK) {
         public Builder withTopK(@NonNull Integer topK) {
-            this.topK = topK;
+            this.topK = topK.longValue();
+            return this;
+        }
+        public Builder withLimit(@NonNull Long limit) {
+            this.topK = limit;
             return this;
             return this;
         }
         }
 
 

+ 24 - 1
sdk-core/src/main/java/io/milvus/v2/service/vector/request/AnnSearchReq.java

@@ -31,7 +31,11 @@ import java.util.List;
 @SuperBuilder
 @SuperBuilder
 public class AnnSearchReq {
 public class AnnSearchReq {
     private String vectorFieldName;
     private String vectorFieldName;
-    private int topK;
+    @Builder.Default
+    @Deprecated
+    private int topK = 0;
+    @Builder.Default
+    private long limit = 0L;
     @Builder.Default
     @Builder.Default
     private String expr = "";
     private String expr = "";
     private List<BaseVector> vectors;
     private List<BaseVector> vectors;
@@ -39,4 +43,23 @@ public class AnnSearchReq {
 
 
     @Builder.Default
     @Builder.Default
     private IndexParam.MetricType metricType = null;
     private IndexParam.MetricType metricType = null;
+
+    public static abstract class AnnSearchReqBuilder<C extends AnnSearchReq, B extends AnnSearchReq.AnnSearchReqBuilder<C, B>> {
+        // topK is deprecated, topK and limit must be the same value
+        public B topK(int val) {
+            this.topK$value = val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+
+        public B limit(long val) {
+            this.topK$value = (int)val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+    }
 }
 }

+ 24 - 1
sdk-core/src/main/java/io/milvus/v2/service/vector/request/HybridSearchReq.java

@@ -20,6 +20,7 @@
 package io.milvus.v2.service.vector.request;
 package io.milvus.v2.service.vector.request;
 
 
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.ConsistencyLevel;
+import io.milvus.v2.service.collection.request.LoadCollectionReq;
 import io.milvus.v2.service.vector.request.ranker.BaseRanker;
 import io.milvus.v2.service.vector.request.ranker.BaseRanker;
 import lombok.Builder;
 import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
@@ -36,7 +37,11 @@ public class HybridSearchReq
     private List<String> partitionNames;
     private List<String> partitionNames;
     private List<AnnSearchReq> searchRequests;
     private List<AnnSearchReq> searchRequests;
     private BaseRanker ranker;
     private BaseRanker ranker;
-    private int topK;
+    @Builder.Default
+    @Deprecated
+    private int topK = 0; // deprecated, replaced by "limit"
+    @Builder.Default
+    private long limit = 0L;
     private List<String> outFields;
     private List<String> outFields;
     private long offset;
     private long offset;
     @Builder.Default
     @Builder.Default
@@ -48,4 +53,22 @@ public class HybridSearchReq
     private Integer groupSize;
     private Integer groupSize;
     private Boolean strictGroupSize;
     private Boolean strictGroupSize;
 
 
+    public static abstract class HybridSearchReqBuilder<C extends HybridSearchReq, B extends HybridSearchReq.HybridSearchReqBuilder<C, B>> {
+        // topK is deprecated, topK and limit must be the same value
+        public B topK(int val) {
+            this.topK$value = val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+
+        public B limit(long val) {
+            this.topK$value = (int)val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+    }
 }
 }

+ 23 - 1
sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReq.java

@@ -1,6 +1,7 @@
 package io.milvus.v2.service.vector.request;
 package io.milvus.v2.service.vector.request;
 
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
+import io.milvus.param.Constant;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.service.vector.request.data.BaseVector;
 import io.milvus.v2.service.vector.request.data.BaseVector;
@@ -21,7 +22,10 @@ public class SearchIteratorReq {
     private IndexParam.MetricType metricType = IndexParam.MetricType.INVALID;
     private IndexParam.MetricType metricType = IndexParam.MetricType.INVALID;
     private String vectorFieldName;
     private String vectorFieldName;
     @Builder.Default
     @Builder.Default
-    private int topK = -1;
+    @Deprecated
+    private int topK = Constant.UNLIMITED;
+    @Builder.Default
+    private long limit = Constant.UNLIMITED_L;
     @Builder.Default
     @Builder.Default
     private String expr = "";
     private String expr = "";
     @Builder.Default
     @Builder.Default
@@ -40,4 +44,22 @@ public class SearchIteratorReq {
     private String groupByFieldName = "";
     private String groupByFieldName = "";
     @Builder.Default
     @Builder.Default
     private long batchSize = 1000L;
     private long batchSize = 1000L;
+
+    public static abstract class SearchIteratorReqBuilder<C extends SearchIteratorReq, B extends SearchIteratorReq.SearchIteratorReqBuilder<C, B>> {
+        // topK is deprecated, topK and limit must be the same value
+        public B topK(int val) {
+            this.topK$value = val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+        public B limit(long val) {
+            this.topK$value = (int)val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+    }
 }
 }

+ 23 - 1
sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchIteratorReqV2.java

@@ -1,6 +1,7 @@
 package io.milvus.v2.service.vector.request;
 package io.milvus.v2.service.vector.request;
 
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
+import io.milvus.param.Constant;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.service.vector.request.data.BaseVector;
 import io.milvus.v2.service.vector.request.data.BaseVector;
@@ -25,7 +26,10 @@ public class SearchIteratorReqV2 {
     private IndexParam.MetricType metricType = IndexParam.MetricType.INVALID;
     private IndexParam.MetricType metricType = IndexParam.MetricType.INVALID;
     private String vectorFieldName;
     private String vectorFieldName;
     @Builder.Default
     @Builder.Default
-    private int topK = -1;
+    @Deprecated
+    private int topK = Constant.UNLIMITED;
+    @Builder.Default
+    private long limit = Constant.UNLIMITED_L;
     @Builder.Default
     @Builder.Default
     private String filter = "";
     private String filter = "";
     @Builder.Default
     @Builder.Default
@@ -46,4 +50,22 @@ public class SearchIteratorReqV2 {
     private long batchSize = 1000L;
     private long batchSize = 1000L;
     @Builder.Default
     @Builder.Default
     private Function<List<SearchResp.SearchResult>, List<SearchResp.SearchResult>> externalFilterFunc = null;
     private Function<List<SearchResp.SearchResult>, List<SearchResp.SearchResult>> externalFilterFunc = null;
+
+    public static abstract class SearchIteratorReqV2Builder<C extends SearchIteratorReqV2, B extends SearchIteratorReqV2.SearchIteratorReqV2Builder<C, B>> {
+        // topK is deprecated, topK and limit must be the same value
+        public B topK(int val) {
+            this.topK$value = val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+        public B limit(long val) {
+            this.topK$value = (int)val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+    }
 }
 }

+ 24 - 2
sdk-core/src/main/java/io/milvus/v2/service/vector/request/SearchReq.java

@@ -22,6 +22,7 @@ package io.milvus.v2.service.vector.request;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.ConsistencyLevel;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.common.IndexParam;
 import io.milvus.v2.service.vector.request.data.BaseVector;
 import io.milvus.v2.service.vector.request.data.BaseVector;
+
 import lombok.Builder;
 import lombok.Builder;
 import lombok.Data;
 import lombok.Data;
 import lombok.experimental.SuperBuilder;
 import lombok.experimental.SuperBuilder;
@@ -41,13 +42,16 @@ public class SearchReq {
     @Builder.Default
     @Builder.Default
     private String annsField = "";
     private String annsField = "";
     private IndexParam.MetricType metricType;
     private IndexParam.MetricType metricType;
-    private int topK;
+    @Builder.Default
+    @Deprecated
+    private int topK = 0;
     private String filter;
     private String filter;
     @Builder.Default
     @Builder.Default
     private List<String> outputFields = new ArrayList<>();
     private List<String> outputFields = new ArrayList<>();
     private List<BaseVector> data;
     private List<BaseVector> data;
     private long offset;
     private long offset;
-    private long limit;
+    @Builder.Default
+    private long limit = 0L;
 
 
     @Builder.Default
     @Builder.Default
     private int roundDecimal = -1;
     private int roundDecimal = -1;
@@ -73,4 +77,22 @@ public class SearchReq {
     //     Boolean, Long, Double, String, List<Boolean>, List<Long>, List<Double>, List<String>
     //     Boolean, Long, Double, String, List<Boolean>, List<Long>, List<Double>, List<String>
     @Builder.Default
     @Builder.Default
     private Map<String, Object> filterTemplateValues = new HashMap<>();
     private Map<String, Object> filterTemplateValues = new HashMap<>();
+
+    public static abstract class SearchReqBuilder<C extends SearchReq, B extends SearchReq.SearchReqBuilder<C, B>> {
+        // topK is deprecated, topK and limit must be the same value
+        public B topK(int val) {
+            this.topK$value = val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+        public B limit(long val) {
+            this.topK$value = (int)val;
+            this.topK$set = true;
+            this.limit$value = val;
+            this.limit$set = true;
+            return self();
+        }
+    }
 }
 }

+ 7 - 5
sdk-core/src/main/java/io/milvus/v2/utils/VectorUtils.java

@@ -184,10 +184,11 @@ public class VectorUtils {
                             .build());
                             .build());
         }
         }
 
 
+        // topK value is deprecated, always use "limit" to set the topK
         builder.addSearchParams(
         builder.addSearchParams(
                         KeyValuePair.newBuilder()
                         KeyValuePair.newBuilder()
                                 .setKey(Constant.TOP_K)
                                 .setKey(Constant.TOP_K)
-                                .setValue(String.valueOf(request.getTopK()))
+                                .setValue(String.valueOf(request.getLimit()))
                                 .build())
                                 .build())
                 .addSearchParams(
                 .addSearchParams(
                         KeyValuePair.newBuilder()
                         KeyValuePair.newBuilder()
@@ -415,7 +416,7 @@ public class VectorUtils {
                 .addSearchParams(
                 .addSearchParams(
                         KeyValuePair.newBuilder()
                         KeyValuePair.newBuilder()
                                 .setKey(Constant.TOP_K)
                                 .setKey(Constant.TOP_K)
-                                .setValue(String.valueOf(annSearchReq.getTopK()))
+                                .setValue(String.valueOf(annSearchReq.getLimit()))
                                 .build());
                                 .build());
         if (annSearchReq.getMetricType() != null) {
         if (annSearchReq.getMetricType() != null) {
             builder.addSearchParams(
             builder.addSearchParams(
@@ -466,10 +467,11 @@ public class VectorUtils {
             throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Ranker is null.");
             throw new MilvusClientException(ErrorCode.INVALID_PARAMS, "Ranker is null.");
         }
         }
 
 
+        // topK value is deprecated, always use "limit" to set the topK
         Map<String, String> props = ranker.getProperties();
         Map<String, String> props = ranker.getProperties();
-        props.put(Constant.LIMIT, String.format("%d", request.getTopK()));
-        props.put(Constant.ROUND_DECIMAL, String.format("%d", request.getRoundDecimal()));
-        props.put(Constant.OFFSET, String.format("%d", request.getOffset()));
+        props.put(Constant.LIMIT, String.valueOf(request.getLimit()));
+        props.put(Constant.ROUND_DECIMAL, String.valueOf(request.getRoundDecimal()));
+        props.put(Constant.OFFSET, String.valueOf(request.getOffset()));
         List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
         List<KeyValuePair> propertiesList = ParamUtils.AssembleKvPair(props);
         if (CollectionUtils.isNotEmpty(propertiesList)) {
         if (CollectionUtils.isNotEmpty(propertiesList)) {
             propertiesList.forEach(builder::addRankParams);
             propertiesList.forEach(builder::addRankParams);

+ 17 - 17
sdk-core/src/test/java/io/milvus/client/MilvusClientDockerTest.java

@@ -651,7 +651,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withFloatVectors(targetVectors)
                 .withFloatVectors(targetVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withParams("{\"ef\":64}")
                 .withParams("{\"ef\":64}")
@@ -854,7 +854,7 @@ class MilvusClientDockerTest {
         SearchParam searchOneParam = SearchParam.newBuilder()
         SearchParam searchOneParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.JACCARD)
                 .withMetricType(MetricType.JACCARD)
-                .withTopK(5)
+                .withLimit(5L)
                 .withBinaryVectors(Collections.singletonList(targetVector))
                 .withBinaryVectors(Collections.singletonList(targetVector))
                 .withVectorFieldName(DataType.BinaryVector.name())
                 .withVectorFieldName(DataType.BinaryVector.name())
                 .addOutField(DataType.BinaryVector.name())
                 .addOutField(DataType.BinaryVector.name())
@@ -921,7 +921,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.HAMMING)
                 .withMetricType(MetricType.HAMMING)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withBinaryVectors(targetVectors)
                 .withBinaryVectors(targetVectors)
                 .withVectorFieldName(DataType.BinaryVector.name())
                 .withVectorFieldName(DataType.BinaryVector.name())
                 .withParams("{\"nprobe\":8}")
                 .withParams("{\"nprobe\":8}")
@@ -1038,7 +1038,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.IP)
                 .withMetricType(MetricType.IP)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withSparseFloatVectors(targetVectors)
                 .withSparseFloatVectors(targetVectors)
                 .withVectorFieldName(DataType.SparseFloatVector.name())
                 .withVectorFieldName(DataType.SparseFloatVector.name())
                 .addOutField(DataType.SparseFloatVector.name())
                 .addOutField(DataType.SparseFloatVector.name())
@@ -1241,7 +1241,7 @@ class MilvusClientDockerTest {
         R<SearchResults> searchR = client.search(SearchParam.newBuilder()
         R<SearchResults> searchR = client.search(SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.COSINE)
                 .withMetricType(MetricType.COSINE)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withFloat16Vectors(Collections.singletonList(fp16Vector))
                 .withFloat16Vectors(Collections.singletonList(fp16Vector))
                 .withVectorFieldName(DataType.Float16Vector.name())
                 .withVectorFieldName(DataType.Float16Vector.name())
                 .addOutField(DataType.Float16Vector.name())
                 .addOutField(DataType.Float16Vector.name())
@@ -1269,7 +1269,7 @@ class MilvusClientDockerTest {
         searchR = client.search(SearchParam.newBuilder()
         searchR = client.search(SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.COSINE)
                 .withMetricType(MetricType.COSINE)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withParams("{\"nprobe\": 16}")
                 .withParams("{\"nprobe\": 16}")
                 .withBFloat16Vectors(Collections.singletonList(bf16Vector))
                 .withBFloat16Vectors(Collections.singletonList(bf16Vector))
                 .withVectorFieldName(DataType.BFloat16Vector.name())
                 .withVectorFieldName(DataType.BFloat16Vector.name())
@@ -1377,7 +1377,7 @@ class MilvusClientDockerTest {
                 .withFloatVectors(utils.generateFloatVectors(1))
                 .withFloatVectors(utils.generateFloatVectors(1))
                 .withMetricType(MetricType.COSINE)
                 .withMetricType(MetricType.COSINE)
                 .withParams("{\"nprobe\": 32}")
                 .withParams("{\"nprobe\": 32}")
-                .withTopK(10)
+                .withLimit(10L)
                 .build();
                 .build();
 
 
         AnnSearchParam param2 = AnnSearchParam.newBuilder()
         AnnSearchParam param2 = AnnSearchParam.newBuilder()
@@ -1385,7 +1385,7 @@ class MilvusClientDockerTest {
                 .withBinaryVectors(utils.generateBinaryVectors(1))
                 .withBinaryVectors(utils.generateBinaryVectors(1))
                 .withMetricType(MetricType.HAMMING)
                 .withMetricType(MetricType.HAMMING)
                 .withParams("{}")
                 .withParams("{}")
-                .withTopK(5)
+                .withLimit(5L)
                 .build();
                 .build();
 
 
         AnnSearchParam param3 = AnnSearchParam.newBuilder()
         AnnSearchParam param3 = AnnSearchParam.newBuilder()
@@ -1393,7 +1393,7 @@ class MilvusClientDockerTest {
                 .withSparseFloatVectors(utils.generateSparseVectors(1))
                 .withSparseFloatVectors(utils.generateSparseVectors(1))
                 .withMetricType(MetricType.IP)
                 .withMetricType(MetricType.IP)
                 .withParams("{\"drop_ratio_search\":0.2}")
                 .withParams("{\"drop_ratio_search\":0.2}")
-                .withTopK(7)
+                .withLimit(7L)
                 .build();
                 .build();
 
 
         HybridSearchParam searchParam = HybridSearchParam.newBuilder()
         HybridSearchParam searchParam = HybridSearchParam.newBuilder()
@@ -1402,7 +1402,7 @@ class MilvusClientDockerTest {
                 .addSearchRequest(param1)
                 .addSearchRequest(param1)
                 .addSearchRequest(param2)
                 .addSearchRequest(param2)
                 .addSearchRequest(param3)
                 .addSearchRequest(param3)
-                .withTopK(3)
+                .withLimit(3L)
                 .withConsistencyLevel(ConsistencyLevelEnum.STRONG)
                 .withConsistencyLevel(ConsistencyLevelEnum.STRONG)
                 .withRanker(WeightedRanker.newBuilder()
                 .withRanker(WeightedRanker.newBuilder()
                         .withWeights(Lists.newArrayList(0.5f, 0.5f, 1.0f))
                         .withWeights(Lists.newArrayList(0.5f, 0.5f, 1.0f))
@@ -1528,7 +1528,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.IP)
                 .withMetricType(MetricType.IP)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withVectors(targetVectors)
                 .withVectors(targetVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .build();
                 .build();
@@ -1775,7 +1775,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.IP)
                 .withMetricType(MetricType.IP)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withFloatVectors(targetVectors)
                 .withFloatVectors(targetVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .addOutField(DataType.Int64.name())
                 .addOutField(DataType.Int64.name())
@@ -2012,7 +2012,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.COSINE)
                 .withMetricType(MetricType.COSINE)
-                .withTopK(topK)
+                .withLimit((long)topK)
                 .withFloatVectors(targetVectors)
                 .withFloatVectors(targetVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withParams("{}")
                 .withParams("{}")
@@ -2187,7 +2187,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
-                .withTopK(5)
+                .withLimit(5L)
                 .withFloatVectors(searchVectors)
                 .withFloatVectors(searchVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .addOutField(varcharArrayName)
                 .addOutField(varcharArrayName)
@@ -2218,7 +2218,7 @@ class MilvusClientDockerTest {
         searchParam = SearchParam.newBuilder()
         searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
-                .withTopK(10)
+                .withLimit(10L)
                 .withExpr(String.format("array_contains_any(%s, [450038, 680015])", intArrayName))
                 .withExpr(String.format("array_contains_any(%s, [450038, 680015])", intArrayName))
                 .withFloatVectors(searchVectors)
                 .withFloatVectors(searchVectors)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
@@ -2789,7 +2789,7 @@ class MilvusClientDockerTest {
                 .withBatchSize(10L)
                 .withBatchSize(10L)
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withVectorFieldName(DataType.FloatVector.name())
                 .withFloatVectors(vectors)
                 .withFloatVectors(vectors)
-                .withTopK(50)
+                .withLimit(50L)
                 .withMetricType(MetricType.L2);
                 .withMetricType(MetricType.L2);
 
 
         R<SearchIterator> sResponse = client.searchIterator(searchIteratorParamBuilder.build());
         R<SearchIterator> sResponse = client.searchIterator(searchIteratorParamBuilder.build());
@@ -3099,7 +3099,7 @@ class MilvusClientDockerTest {
         SearchParam searchParam = SearchParam.newBuilder()
         SearchParam searchParam = SearchParam.newBuilder()
                 .withCollectionName(randomCollectionName)
                 .withCollectionName(randomCollectionName)
                 .withMetricType(MetricType.L2)
                 .withMetricType(MetricType.L2)
-                .withTopK(10)
+                .withLimit(10L)
                 .withFloatVectors(searchVectors)
                 .withFloatVectors(searchVectors)
                 .withVectorFieldName("vector")
                 .withVectorFieldName("vector")
                 .withParams("{}")
                 .withParams("{}")

+ 14 - 14
sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java

@@ -455,7 +455,7 @@ class MilvusClientV2DockerTest {
                 .partitionNames(Collections.singletonList(partitionName))
                 .partitionNames(Collections.singletonList(partitionName))
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
                 .data(Collections.singletonList(new FloatVec(utils.generateFloatVector())))
                 .data(Collections.singletonList(new FloatVec(utils.generateFloatVector())))
-                .topK(10)
+                .limit(10)
                 .build());
                 .build());
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
         Assertions.assertEquals(1, searchResults.size());
         Assertions.assertEquals(1, searchResults.size());
@@ -501,7 +501,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
                 .data(targetVectors)
                 .data(targetVectors)
-                .topK(10)
+                .limit(topk)
                 .outputFields(Collections.singletonList("*"))
                 .outputFields(Collections.singletonList("*"))
                 .build());
                 .build());
         searchResults = searchResp.getSearchResults();
         searchResults = searchResp.getSearchResults();
@@ -586,7 +586,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
                 .data(targetVectors)
                 .data(targetVectors)
-                .topK(10)
+                .limit(topk)
                 .outputFields(Collections.singletonList(vectorFieldName))
                 .outputFields(Collections.singletonList(vectorFieldName))
                 .build());
                 .build());
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
@@ -688,7 +688,7 @@ class MilvusClientV2DockerTest {
                     .collectionName(randomCollectionName)
                     .collectionName(randomCollectionName)
                     .annsField(float16Field)
                     .annsField(float16Field)
                     .data(Collections.singletonList(new Float16Vec(originVector)))
                     .data(Collections.singletonList(new Float16Vec(originVector)))
-                    .topK(topk)
+                    .limit(topk)
                     .consistencyLevel(ConsistencyLevel.STRONG)
                     .consistencyLevel(ConsistencyLevel.STRONG)
                     .outputFields(Collections.singletonList(float16Field))
                     .outputFields(Collections.singletonList(float16Field))
                     .build());
                     .build());
@@ -714,7 +714,7 @@ class MilvusClientV2DockerTest {
                     .collectionName(randomCollectionName)
                     .collectionName(randomCollectionName)
                     .annsField(bfloat16Field)
                     .annsField(bfloat16Field)
                     .data(Collections.singletonList(new BFloat16Vec(originVector)))
                     .data(Collections.singletonList(new BFloat16Vec(originVector)))
-                    .topK(topk)
+                    .limit(topk)
                     .consistencyLevel(ConsistencyLevel.STRONG)
                     .consistencyLevel(ConsistencyLevel.STRONG)
                     .outputFields(Collections.singletonList(bfloat16Field))
                     .outputFields(Collections.singletonList(bfloat16Field))
                     .build());
                     .build());
@@ -797,7 +797,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
                 .data(targetVectors)
                 .data(targetVectors)
-                .topK(topk)
+                .limit(topk)
                 .build());
                 .build());
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
         List<List<SearchResp.SearchResult>> searchResults = searchResp.getSearchResults();
         Assertions.assertEquals(nq, searchResults.size());
         Assertions.assertEquals(nq, searchResults.size());
@@ -911,7 +911,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField(vectorFieldName)
                 .annsField(vectorFieldName)
                 .data(targetVectors)
                 .data(targetVectors)
-                .topK(topK)
+                .limit(topK)
                 .outputFields(Collections.singletonList("*"))
                 .outputFields(Collections.singletonList("*"))
                 .consistencyLevel(ConsistencyLevel.STRONG)
                 .consistencyLevel(ConsistencyLevel.STRONG)
                 .build());
                 .build());
@@ -1029,24 +1029,24 @@ class MilvusClientV2DockerTest {
                 .vectorFieldName("float_vector")
                 .vectorFieldName("float_vector")
                 .vectors(floatVectors)
                 .vectors(floatVectors)
                 .params("{\"nprobe\": 10}")
                 .params("{\"nprobe\": 10}")
-                .topK(10)
+                .limit(10)
                 .build());
                 .build());
         searchRequests.add(AnnSearchReq.builder()
         searchRequests.add(AnnSearchReq.builder()
                 .vectorFieldName("binary_vector")
                 .vectorFieldName("binary_vector")
                 .vectors(binaryVectors)
                 .vectors(binaryVectors)
-                .topK(50)
+                .limit(50)
                 .build());
                 .build());
         searchRequests.add(AnnSearchReq.builder()
         searchRequests.add(AnnSearchReq.builder()
                 .vectorFieldName("sparse_vector")
                 .vectorFieldName("sparse_vector")
                 .vectors(sparseVectors)
                 .vectors(sparseVectors)
-                .topK(100)
+                .limit(100)
                 .build());
                 .build());
 
 
         HybridSearchReq hybridSearchReq = HybridSearchReq.builder()
         HybridSearchReq hybridSearchReq = HybridSearchReq.builder()
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .searchRequests(searchRequests)
                 .searchRequests(searchRequests)
                 .ranker(new RRFRanker(20))
                 .ranker(new RRFRanker(20))
-                .topK(topk)
+                .limit(topk)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .build();
                 .build();
         SearchResp searchResp = client.hybridSearch(hybridSearchReq);
         SearchResp searchResp = client.hybridSearch(hybridSearchReq);
@@ -1606,7 +1606,7 @@ class MilvusClientV2DockerTest {
                 .vectors(Collections.singletonList(new FloatVec(utils.generateFloatVector())))
                 .vectors(Collections.singletonList(new FloatVec(utils.generateFloatVector())))
                 .expr("int64_field > 500 && int64_field < 1000")
                 .expr("int64_field > 500 && int64_field < 1000")
                 .params("{\"range_filter\": 5.0, \"radius\": 50.0}")
                 .params("{\"range_filter\": 5.0, \"radius\": 50.0}")
-                .topK(1000)
+                .limit(1000)
                 .metricType(IndexParam.MetricType.L2)
                 .metricType(IndexParam.MetricType.L2)
                 .consistencyLevel(ConsistencyLevel.EVENTUALLY)
                 .consistencyLevel(ConsistencyLevel.EVENTUALLY)
                 .build());
                 .build());
@@ -2211,7 +2211,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField("vector")
                 .annsField("vector")
                 .data(Collections.singletonList(new FloatVec(utils.generateFloatVector(dim))))
                 .data(Collections.singletonList(new FloatVec(utils.generateFloatVector(dim))))
-                .topK(10)
+                .limit(10)
                 .outputFields(Lists.newArrayList("*"))
                 .outputFields(Lists.newArrayList("*"))
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .consistencyLevel(ConsistencyLevel.BOUNDED)
                 .build());
                 .build());
@@ -2341,7 +2341,7 @@ class MilvusClientV2DockerTest {
                 .collectionName(randomCollectionName)
                 .collectionName(randomCollectionName)
                 .annsField("sparse")
                 .annsField("sparse")
                 .data(Collections.singletonList(new EmbeddedText("milvus AI")))
                 .data(Collections.singletonList(new EmbeddedText("milvus AI")))
-                .topK(10)
+                .limit(10)
                 .outputFields(Lists.newArrayList("*"))
                 .outputFields(Lists.newArrayList("*"))
                 .metricType(IndexParam.MetricType.BM25)
                 .metricType(IndexParam.MetricType.BM25)
                 .build());
                 .build());

+ 2 - 2
sdk-core/src/test/java/io/milvus/v2/service/vector/VectorTest.java

@@ -96,7 +96,7 @@ class VectorTest extends BaseTest {
         SearchReq request = SearchReq.builder()
         SearchReq request = SearchReq.builder()
                 .collectionName("test2")
                 .collectionName("test2")
                 .data(Collections.singletonList(new FloatVec(vectorList)))
                 .data(Collections.singletonList(new FloatVec(vectorList)))
-                .topK(10)
+                .limit(10)
                 .offset(0L)
                 .offset(0L)
                 .build();
                 .build();
         SearchResp statusR = client_v2.search(request);
         SearchResp statusR = client_v2.search(request);
@@ -123,7 +123,7 @@ class VectorTest extends BaseTest {
             SearchReq request = SearchReq.builder()
             SearchReq request = SearchReq.builder()
                     .collectionName("test")
                     .collectionName("test")
                     .data(Collections.singletonList(new FloatVec(vectorList)))
                     .data(Collections.singletonList(new FloatVec(vectorList)))
-                    .topK(10)
+                    .limit(10)
                     .offset(0L)
                     .offset(0L)
                     .filter(key)
                     .filter(key)
                     .filterTemplateValues(value)
                     .filterTemplateValues(value)