Browse Source

fix highLevel-API error (#539) (#540)

xushuang.hu 2 years ago
parent
commit
225d1487ae

+ 3 - 2
examples/main/java/io/milvus/HighLevelExample.java

@@ -50,8 +50,8 @@ public class HighLevelExample {
 
 
     static {
     static {
         ConnectParam connectParam = ConnectParam.newBuilder()
         ConnectParam connectParam = ConnectParam.newBuilder()
-                .withUri("https://in01-a00c28dbbf13e49.aws-us-west-2.vectordb-uat3.zillizcloud.com:19535")
-                .withAuthorization("db_admin","Easou!234")
+                .withUri("https://in01-cdac4a1608b0931.aws-us-west-2.vectordb-uat3.zillizcloud.com:19540")
+                .withAuthorization("root","Milvus")
                 .build();
                 .build();
         milvusClient = new MilvusServiceClient(connectParam);
         milvusClient = new MilvusServiceClient(connectParam);
     }
     }
@@ -222,6 +222,7 @@ public class HighLevelExample {
         QuerySimpleParam querySimpleParam = QuerySimpleParam.newBuilder()
         QuerySimpleParam querySimpleParam = QuerySimpleParam.newBuilder()
                 .withCollectionName(COLLECTION_NAME)
                 .withCollectionName(COLLECTION_NAME)
                 .withFilter(filter)
                 .withFilter(filter)
+                .withOutputFields(Lists.newArrayList("int32", "int64"))
                 .withLimit(100L)
                 .withLimit(100L)
                 .withOffset(0L)
                 .withOffset(0L)
                 .build();
                 .build();

+ 14 - 2
src/main/java/io/milvus/param/highlevel/dml/QuerySimpleParam.java

@@ -61,8 +61,8 @@ public class QuerySimpleParam {
         private String collectionName;
         private String collectionName;
         private final List<String> outputFields = new ArrayList<>();
         private final List<String> outputFields = new ArrayList<>();
         private String filter = "";
         private String filter = "";
-        private Long offset;
-        private Long limit;
+        private Long offset = 0L;
+        private Long limit = 0L;
 
 
         private Builder() {
         private Builder() {
         }
         }
@@ -84,11 +84,23 @@ public class QuerySimpleParam {
          * @param outFields output fields
          * @param outFields output fields
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withOutFields(@NonNull List<String> outFields) {
         public Builder withOutFields(@NonNull List<String> outFields) {
             this.outputFields.addAll(outFields);
             this.outputFields.addAll(outFields);
             return this;
             return this;
         }
         }
 
 
+        /**
+         * Specifies output fields (Optional).
+         *
+         * @param outputFields output fields
+         * @return <code>Builder</code>
+         */
+        public Builder withOutputFields(@NonNull List<String> outputFields) {
+            this.outputFields.addAll(outputFields);
+            return this;
+        }
+
         /**
         /**
          * Sets the expression to query entities.
          * Sets the expression to query entities.
          * @see <a href="https://milvus.io/docs/v2.0.0/boolean.md">Boolean Expression Rules</a>
          * @see <a href="https://milvus.io/docs/v2.0.0/boolean.md">Boolean Expression Rules</a>

+ 17 - 3
src/main/java/io/milvus/param/highlevel/dml/SearchSimpleParam.java

@@ -70,8 +70,8 @@ public class SearchSimpleParam {
         private List<?> vectors;
         private List<?> vectors;
         private final List<String> outputFields = Lists.newArrayList();
         private final List<String> outputFields = Lists.newArrayList();
         private String filter = "";
         private String filter = "";
-        private Long offset;
-        private int limit;
+        private Long offset = 0L;
+        private int limit = 10;
 
 
         private final Map<String, Object> params = new HashMap<>();
         private final Map<String, Object> params = new HashMap<>();
 
 
@@ -139,16 +139,30 @@ public class SearchSimpleParam {
 
 
         /**
         /**
          * Specify a value to control the returned number of entities. Must be a positive value.
          * Specify a value to control the returned number of entities. Must be a positive value.
-         * Default value is 0, will return without limit.
+         * Default value is 10, will return without limit.
          *
          *
          * @param limit a value to define the limit of returned entities
          * @param limit a value to define the limit of returned entities
          * @return <code>Builder</code>
          * @return <code>Builder</code>
          */
          */
+        @Deprecated
         public Builder withLimit(int limit) {
         public Builder withLimit(int limit) {
             this.limit = limit;
             this.limit = limit;
             return this;
             return this;
         }
         }
 
 
+        /**
+         * Specify a value to control the returned number of entities. Must be a positive value.
+         * Default value is 10, will return without limit.
+         * To maintain consistency with the parameter type of the query interface, the field is declared as Long. In reality, the field is of type int.
+         *
+         * @param limit a value to define the limit of returned entities
+         * @return <code>Builder</code>
+         */
+        public Builder withLimit(@NonNull Long limit) {
+            this.limit = Math.toIntExact(limit);
+            return this;
+        }
+
         /**
         /**
          * Verifies parameters and creates a new {@link SearchSimpleParam} instance.
          * Verifies parameters and creates a new {@link SearchSimpleParam} instance.
          *
          *