diff --git a/docker-compose.yml b/docker-compose.yml index 85b6fdcef..803b035a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: standalone: container_name: milvus-javasdk-test-standalone - image: milvusdb/milvus:v2.5.8 + image: milvusdb/milvus:v2.5.11 command: ["milvus", "run", "standalone"] environment: ETCD_ENDPOINTS: etcd:2379 diff --git a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java index 168bdb488..4d98a9658 100644 --- a/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java +++ b/sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java @@ -249,12 +249,22 @@ public void createCollection(CreateCollectionReq request) { } /** - * Creates a collection schema. + * Creates a collection schema. This method is deprecated from v2.5.9, replaced by CreateSchema() * @return CreateCollectionReq.CollectionSchema */ + @Deprecated public CreateCollectionReq.CollectionSchema createSchema() { - return collectionService.createSchema(); + return CollectionService.createSchema(); } + + /** + * Creates a collection schema. + * @return CreateCollectionReq.CollectionSchema + */ + public static CreateCollectionReq.CollectionSchema CreateSchema() { + return CollectionService.createSchema(); + } + /** * list milvus collections * diff --git a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java index 5499ad9fe..102d37de0 100644 --- a/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java +++ b/sdk-core/src/main/java/io/milvus/v2/service/collection/CollectionService.java @@ -357,7 +357,7 @@ public GetCollectionStatsResp getCollectionStats(MilvusServiceGrpc.MilvusService return getCollectionStatsResp; } - public CreateCollectionReq.CollectionSchema createSchema() { + public static CreateCollectionReq.CollectionSchema createSchema() { return CreateCollectionReq.CollectionSchema.builder() .build(); } diff --git a/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java b/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java index 5756b6b7d..9c7e19b92 100644 --- a/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java +++ b/sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java @@ -91,11 +91,22 @@ public DescribeIndexResp convertToDescribeIndexResp(List respo Map properties = new HashMap<>(); for(KeyValuePair param : params) { if (param.getKey().equals(Constant.INDEX_TYPE)) { - // may throw IllegalArgumentException - indexType = IndexParam.IndexType.valueOf(param.getValue().toUpperCase()); + try { + indexType = IndexParam.IndexType.valueOf(param.getValue().toUpperCase()); + } catch (IllegalArgumentException e) { + // if the server has new index type but sdk version is old + e.printStackTrace(); + } } else if (param.getKey().equals(Constant.METRIC_TYPE)) { - // may throw IllegalArgumentException - metricType = IndexParam.MetricType.valueOf(param.getValue()); + // for scalar index such as Trie/STL_SORT, the param.getValue() is empty, no need to parse it + if (!param.getValue().isEmpty()) { + try { + metricType = IndexParam.MetricType.valueOf(param.getValue()); + } catch (IllegalArgumentException e) { + // if the server has new metric type but sdk version is old + e.printStackTrace(); + } + } } else if (param.getKey().equals(Constant.MMAP_ENABLED)) { properties.put(param.getKey(), param.getValue()); // just for compatible with old versions extraParams.put(param.getKey(), param.getValue()); diff --git a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java index 8e4a9c969..568ff5317 100644 --- a/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java +++ b/sdk-core/src/test/java/io/milvus/v2/client/MilvusClientV2DockerTest.java @@ -1156,6 +1156,10 @@ void testIndex() { .metricType(IndexParam.MetricType.COSINE) .extraParams(extra) .build()); + indexes.add(IndexParam.builder() + .fieldName("name") + .indexType(IndexParam.IndexType.TRIE) + .build()); client.createCollection(CreateCollectionReq.builder() .collectionName(randomCollectionName) .collectionSchema(collectionSchema) @@ -1217,12 +1221,20 @@ void testIndex() { collProps = descCollResp.getProperties(); Assertions.assertFalse(collProps.containsKey("prop")); - // index alter properties + // describe scalar index DescribeIndexResp descResp = client.describeIndex(DescribeIndexReq.builder() + .collectionName(randomCollectionName) + .fieldName("name") + .build()); + DescribeIndexResp.IndexDesc desc = descResp.getIndexDescByFieldName("name"); + Assertions.assertEquals(IndexParam.IndexType.TRIE, desc.getIndexType()); + + // index alter properties + descResp = client.describeIndex(DescribeIndexReq.builder() .collectionName(randomCollectionName) .fieldName("vector") .build()); - DescribeIndexResp.IndexDesc desc = descResp.getIndexDescByFieldName("vector"); + desc = descResp.getIndexDescByFieldName("vector"); Assertions.assertEquals("vector", desc.getFieldName()); Assertions.assertFalse(desc.getIndexName().isEmpty()); Assertions.assertEquals(IndexParam.IndexType.HNSW, desc.getIndexType()); @@ -1270,7 +1282,7 @@ void testIndex() { // drop index client.dropIndex(DropIndexReq.builder() .collectionName(randomCollectionName) - .fieldName("vector") + .indexName("vector") .build()); IndexParam param = IndexParam.builder() diff --git a/tests/milvustest/pom.xml b/tests/milvustest/pom.xml index b5406c0be..423a22494 100644 --- a/tests/milvustest/pom.xml +++ b/tests/milvustest/pom.xml @@ -89,7 +89,7 @@ com.google.protobuf protobuf-java - 3.24.0 + 3.25.5