diff --git a/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java b/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java index 4ea6c47ea..829debc15 100644 --- a/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java +++ b/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java @@ -2883,7 +2883,7 @@ public R delete(DeleteIdsParam requestParam) { .build(); R resultR = delete(deleteParam); MutationResultWrapper resultWrapper = new MutationResultWrapper(resultR.getData()); - return R.success(DeleteResponse.builder().deleteIds(resultWrapper.getInsertIDs()).build()); + return R.success(DeleteResponse.builder().deleteIds(resultWrapper.getDeleteIDs()).build()); } catch (StatusRuntimeException e) { logError("Delete RPC failed! Collection name:{}", requestParam.getCollectionName(), e); diff --git a/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java b/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java index 9a5e15984..dc2522c5d 100644 --- a/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java +++ b/src/main/java/io/milvus/param/highlevel/dml/response/DeleteResponse.java @@ -32,5 +32,10 @@ @Getter @ToString public class DeleteResponse { + /** + * In the new version, this method only returns an empty list and does not return specific values + * Mark is as deprecated, keep it to compatible with the legacy code + */ + @Deprecated public List deleteIds; } diff --git a/src/main/java/io/milvus/response/MutationResultWrapper.java b/src/main/java/io/milvus/response/MutationResultWrapper.java index b9eac8276..6a532cf99 100644 --- a/src/main/java/io/milvus/response/MutationResultWrapper.java +++ b/src/main/java/io/milvus/response/MutationResultWrapper.java @@ -1,5 +1,6 @@ package io.milvus.response; +import com.google.common.collect.Lists; import io.milvus.exception.ParamException; import io.milvus.grpc.MutationResult; @@ -70,6 +71,21 @@ public List getInsertIDs() { } } + /** + * Gets the ID array from returned by delete interface. + * + * @return List of Ids, ID array returned by delete interface + */ + public List getDeleteIDs() { + if (result.getIDs().hasIntId()) { + return result.getIDs().getIntId().getDataList(); + } else if (result.getIDs().hasStrId()) { + return result.getIDs().getStrId().getDataList(); + } else { + return Lists.newArrayList(); + } + } + /** * Gets the row count of the deleted entities. Currently, this value is always equal to input row count * diff --git a/src/test/java/io/milvus/client/MilvusClientDockerTest.java b/src/test/java/io/milvus/client/MilvusClientDockerTest.java index 681821420..f2655b66d 100644 --- a/src/test/java/io/milvus/client/MilvusClientDockerTest.java +++ b/src/test/java/io/milvus/client/MilvusClientDockerTest.java @@ -1680,6 +1680,5 @@ private static void testHighLevelDelete(String collectionName, List primaryIds) String outPutStr = String.format("collectionName:%s, primaryIds:%s, deleteResponseR:%s", collectionName, primaryIds, deleteResponseR); System.out.println(outPutStr); Assertions.assertEquals(R.Status.Success.getCode(), deleteResponseR.getStatus().intValue()); - Assertions.assertEquals(primaryIds.size(), deleteResponseR.getData().getDeleteIds().size()); } }