bulkInsert()
A MilvusClient interface. This method imports data from external files, currently supports JSON/Numpy/Parquet files. Read the doc for details.
R<ImportResponse> bulkInsert(BulkInsertParam requestParam);
BulkInsertParam
Use the BulkInsertParam.Builder
to construct a BulkInsertParam
object.
import io.milvus.param.BulkInsertParam;
BulkInsertParam.Builder builder = BulkInsertParam.newBuilder();
Methods of BulkInsertParam.Builder
:
Method |
Description |
Parameters |
---|---|---|
withCollectionName(String collectionName) |
Sets the collection name. Collection name cannot be empty or null. |
collectionName: The name of the target collection. |
withDatabaseName(String databaseName) |
Sets the database name. database name can be null for default database. |
databaseName: The database name. |
withPartitionName(String partitionName) |
Sets the partition name. partition name can be null. |
partitionName: The name of the target partition. |
withFiles(List<String> files) |
Sets the path of the files. The paths cannot be empty or null. |
files: A file paths list. Currently, you can only input one row-based JSON file for each call. |
addFile(String file) |
Set a file path to be imported.The paths cannot be empty or null. |
file: A file path. |
build() |
Constructs a BulkInsertParam object. |
N/A |
The BulkInsertParam.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<ImportResponse>
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
ImportResponse
held by theR
template. You can useImportResponse
to get the task ID.
Example
import io.milvus.param.bulkinsert.*;
List<String> files = Arrays.asList("/path_to_bucket/data.json");
R<ImportResponse> response = milvusClient.bulkInsert(BulkInsertParam.newBuilder()
.withCollectionName(COLLECTION_NAME)
.withFiles(files)
.build());
if (response.getStatus() != R.Status.Success.getCode()) {
System.out.println(response.getMessage());
}