Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
19 changes: 15 additions & 4 deletions sdk-core/src/main/java/io/milvus/v2/utils/ConvertUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,22 @@ public DescribeIndexResp convertToDescribeIndexResp(List<IndexDescription> respo
Map<String, String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -1270,7 +1282,7 @@ void testIndex() {
// drop index
client.dropIndex(DropIndexReq.builder()
.collectionName(randomCollectionName)
.fieldName("vector")
.indexName("vector")
.build());

IndexParam param = IndexParam.builder()
Expand Down
2 changes: 1 addition & 1 deletion tests/milvustest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.24.0</version>
<version>3.25.5</version>
</dependency>
<!--Allure-->
<dependency>
Expand Down
Loading