delete()
A MilvusClient interface. This method deletes entity(s) based on the primary key ids.
R<DeleteResponse> delete(DeleteIdsParam requestParam);
DeleteIdsParam
Use the DeleteIdsParam.Builder
to construct a DeleteIdsParam
object.
import io.milvus.param.highlevel.dml.DeleteIdsParam;
DeleteIdsParam.Builder builder = DeleteIdsParam.newBuilder();
Methods of DeleteIdsParam.Builder
:
Method | Description | Parameters |
---|---|---|
withCollectionName(String collectionName) | Sets the target collection name. Collection name cannot be empty or null. | collectionName: The name of the collection to insert data into. |
withPartitionName(tring partitionName) | Sets the partition name (Optional). | partitionName: The target partition name. |
withPrimaryIds(List<T> primaryIds) | Specifies primaryField ids. PrimaryIds cannot be empty or null. | primaryIds: A list of primary field id. |
addPrimaryId(T primaryId) | Specifies primaryField id. PrimaryId cannot be empty or null. | primaryId: The id of primary field key. |
build() | Constructs an DeleteIdsParam object. | N/A |
The DeleteIdsParam.Builder.build()
can throw the following exceptions:
- ParamException: error if the parameter is invalid.
Returns
This method catches all the exceptions and returns an R<DeleteResponse>
object.
-
If the API fails on the server side, it returns the error code and message from the server.
-
If the API fails by RPC exception, it returns
R.Status.Unknown
and the error message of the exception. -
If the API succeeds, it returns a valid
DeleteResponse
held by theR
template.
Example
import io.milvus.param.highlevel.*;
import io.milvus.response.MutationResultWrapper;
import io.milvus.grpc.MutationResult;
List<String> ids = Lists.newArrayList("441966745769900131", "441966745769900133");
DeleteIdsParam param = DeleteIdsParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.withPrimaryIds(ids)
.build();
R<DeleteResponse> response = client.delete(param);
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}
for (Object deleteId : response.getData().getDeleteIds()) {
System.out.println(deleteId);
}