跳到主要内容

bulkImport()

Addedv2.5.x

This operation imports the prepared data files to Zilliz Cloud. To learn how to prepare your data files, read Prepare Data Import.

public static String bulkImport(String url, BaseImportRequest request)

Request Syntax

bulkImport.bulkImport(
url,
request
)

PARAMETERS:

  • url (String) -

    Zilliz Cloud's Control Plane API endpoint. The endpoint URL should be in the following format:

    https://api.cloud.zilliz.com
    # https://api.cloud.zilliz.com.cn
  • request (BaseImportRequest) -

    A BaseImportRequest instance.

RETURN TYPE:

String

RETURNS:

The ID of the created import job.

BaseImportRequest

A BaseImportRequest instance is implemented in CloudImportRequest.

CloudImportRequest

CloudImportRequest.builder()
.apiKey(String apiKey)
.objectUrl(String objectUrl)
.accessKey(String accessKey)
.secrectKey(String secrectKey)
.clusterId(String clusterId)
.dbName(String dbName)
.collectionName(String collectionName)
.partitionName(String partitionName)
.build()

BUILDER METHODS:

  • apiKey(String apiKey)

    A valid Zilliz Cloud API key with sufficient permissions to manipulate the cluster.

  • objectUrl(String objectUrl)

    The URL of your data files in one of your block storage buckets. The following are some examples of some renowned block storage services:

    # Google Cloud Storage
    gs://{bucket-name}/{object-path}/

    # AWS S3
    s3://{bucket-name}/{object-path}/
  • accessKey(String accessKey)

    The access key that is used to authenticate access to your data files.

  • secrectKey(String secrectKey)

    The secret key that is used to authenticate access to your data files.

  • clusterId(String clusterId)

    The instance ID of the target cluster of this operation.

    You can get the instance ID of a cluster on its details page from the Zilliz Cloud console.

  • dbName(String dbName)

    The name of the target database. The value of this parameter defaults to default.

  • collectionName(String collectionName)

    The name of a collection in the target cluster of this operation.

  • partitionName(String partitionName)

    The name of the partition in the target cluster of this operation. The value defaults to default.

Example

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import io.milvus.bulkwriter.request.import_.MilvusImportRequest;
import io.milvus.bulkwriter.restful.BulkImportUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

CloudImportRequest cloudImportRequest = CloudImportRequest.builder()
.objectUrl(objectUrl).accessKey(accessKey).secretKey(secretKey)
.clusterId(clusterId).collectionName(collectionName)
.apiKey(apiKey)
.build();
String bulkImportResult = BulkImportUtils.bulkImport(url, cloudImportRequest);

Gson GSON_INSTANCE = new Gson();
JsonObject result = GSON_INSTANCE.fromJson(bulkImportResult, JsonObject.class);
String jobId = result.getAsJsonObject("data").get("jobId").getAsString();
System.out.println("Create a bulkInert task, job id: " + jobId);