Creates a data migration task to migrate data from a specified Elasticsearch cluster to the current Elasticsearch cluster.
Before you call this operation, take note of the following points:
- Currently, the one-click index migration feature is available only in the China (Beijing) region.
- The source and destination Elasticsearch clusters must be self-built or Alibaba Cloud Elasticsearch Elasticsearch clusters of source V6.7.0 and Alibaba Cloud Elasticsearch Elasticsearch clusters of V6.3.2 or V6.7.0.
Debugging
Request headers
This operation uses only common request headers. For more information, see Common request headers.
Request syntax
POST /openapi/instances/{InstanceId}/data-task HTTP/1.1
Request parameters
Parameter | Type | Position | Required | Example | Description |
---|---|---|---|---|---|
ClientToken | String | Query | No | 5A2CFF0E-5718-45B5-9D4D-70B3FF**** | The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. |
InstanceId | String | Path | Yes | es-cn-n6w1o1x0w001c**** | The ID of the destination cluster to which the index is migrated. |
Array | Body | No | The request body. |
||
sourceCluster | Object | Body | No | The information about the source cluster. |
|
dataSourceType | String | Body | Yes | elasticsearch | The type of the source cluster. The default value is Elasticsearch. |
endpoint | String | Body | No | http://yourdomain.com | The public domain name of the cluster. You can specify this parameter when the source cluster is set to Internet-enabled. |
vpcInstanceId | String | Body | No | es-xxx-worker | The ID of the current cluster or SLB(Server Load Balancer) instance. The source cluster is connected by using the VPC information. |
username | String | Body | No | elastic | The logon username of the source cluster. |
password | String | Body | No | es_password | The logon password of the source cluster. |
index | String | Body | Yes | index_001 | The index of the source cluster. |
type | String | Body | Yes | index_001 | The data type of the source cluster index. |
vpcInstancePort | Integer | Body | No | 9200 | The port number used to access the cluster. The source cluster is connected by using the VPC information. |
vpcId | String | Body | No | vpc-xxx | The ID of the VPC to which the cluster belongs. The source cluster is connected by using the VPC information. Note If the endpoint is a public domain name, you can specify this parameter. If the endpoint is a private domain name, you must specify this parameter. |
sinkCluster | Object | Body | No | The information about the destination cluster. |
|
dataSourceType | String | Body | Yes | elasticsearch | The type of the destination cluster. |
username | String | Body | Yes | elastic | The logon username of the target cluster. |
password | String | Body | Yes | xxxxx | The logon password of the destination cluster. |
index | String | Body | Yes | index_001 | The specified index of the destination cluster. |
type | String | Body | Yes | index_001 | Specifies the type of the index. |
settings | String | Body | Yes | {\n \"index\": {\n \"replication\": {\n \"type\": .....} | Settings. |
mapping | String | Body | Yes | {\"doc\":{\"properties\":{\"interval_ms\":{\"type\":\"long\"},....} | The mapping configuration. |
routing | String | Body | No | _id | The index routing field. By default, the primary key field is used. |
migrateConfig | Object | Body | No | Migrate configurations. |
|
sourceFilterParams | String | Body | No | index=111 | The filter conditions of the index. You can use the filter conditions to filter documents that meet the specified conditions to rebuild the index. |
- If the cluster is enabled over the Internet, enter the endpoint parameter to connect to the cluster.
- If the public network of the cluster is disabled (or the cluster is connected by using VPC information), enter the vpcInstancePort, vpcId, vpcInstanceId, or vpcInstancePort, vpcId, and vpcIp parameters to connect to the cluster.
Example:
- Access the cluster over the Internet
{ "sourceCluster":{ "dataSourceType":"elasticsearch", "endpoint" : "http://es-cn-n6w1o1x0w001c****.public.elasticsearch.aliyuncs.com:9200", "username" : "elastic", "password" : "xxxxxx", "index" : "default", "type" : "default" }, "sinkCluster":{ "dataSourceType":"elasticsearch", "username" : "elastic", "password" : "xxxxxx", "index" : "default", "type" : "default", "settings" : "#settings configuration#", "mapping" : "#mapping configuration#", "routing" : "_id" }, "migrateConfig": { "sourceFilterParams": "" } }
- Alibaba Cloud Elasticsearch Cluster
{ "sourceCluster":{ "dataSourceType" : "elasticsearch", "vpcInstancePort":9200, "vpcId":"vpc-2ze55voww95g82gak****", "vpcInstanceId":"es-cn-oew1oxiro000f****-worker", "username" : "elastic", "password" : "xxxxxx", "index" : "default", "type" : "default" }, "sinkCluster":{ "dataSourceType":"elasticsearch", "username" : "elastic", "password" : "xxxxxx", "index" : "default", "type" : "default", "settings" : "#settings configuration#", "mapping" : "#mapping configuration#", "routing" : "_id" }, "migrateConfig": { "sourceFilterParams": "" } }
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 5FFD9ED4-C2EC-4E89-B22B-1ACB6FE1**** | The request ID. |
Result | Array of Result | The response parameters. |
|
sourceCluster | Object | The information about the source cluster. |
|
password | String | xxxxxx | The password that is used to access the source cluster. |
index | String | index_001 | The indexes that you want to migrate. |
type | String | index_001 | The type of the specified index. |
endpoint | String | http://10.20.xx.xx:9200 | The public domain name of the cluster. |
username | String | elastic | The username of the source cluster. |
vpcId | String | vpc-2ze55voww95g82gak**** | The ID of the Virtual Private Cloud to which the source cluster belongs. You can specify this parameter if the cluster endpoint is a public endpoint. You must specify a private endpoint. |
vpcInstanceId | String | es-cn-oew1oxiro000f****-worker | The ID of the cluster under the Virtual Private Cloud, or the ID of the SLB instance. |
vpcInstancePort | Integer | 9200 | The access port number of the source cluster. |
dataSourceType | String | elasticsearch | The type of the source cluster. Default value: Elasticsearch. |
sinkCluster | Object | The information about the destination cluster. |
|
password | String | xxxxx | The password that is used to access the destination cluster. |
index | String | index_001 | The name of the target index. |
settings | String | {\n \"index\": {\n \"replication\": {\n \"type\": .....} | Settings. |
mapping | String | {\"doc\":{\"properties\":{\"interval_ms\":{\"type\":\"long\"},....} | The mapping configuration. |
type | String | index_001 | The type of the target index. |
routing | String | cluster_name | The routing field. By default, the primary key field is used. |
username | String | elastic | The username of the destination cluster. |
vpcId | String | vpc-2ze55voww95g82gak**** | The ID of the Virtual Private Cloud to which the cluster belongs. If the cluster endpoint is a public domain name, you can specify this parameter. If the cluster endpoint is a private endpoint, you must specify this parameter. |
vpcInstancePort | String | 9200 | The cluster access port number. |
vpcInstanceId | String | es-cn-oew1oxiro000f****-worker | The ID of the cluster under the Virtual Private Cloud, or the ID of the SLB instance. |
dataSourceType | String | elasticsearch | The type of the destination cluster. |
Examples
Sample requests
POST /openapi/instances/es-cn-n6w1o1x0w001c****/data-task?ClientToken=5A2CFF0E-5718-45B5-9D4D-70B3FF**** HTTP/1.1
Host:elasticsearch.aliyuncs.com
Content-Type:application/json
[ {
"sourceCluster":{
"dataSourceType":"elasticsearch",
"endpoint" : "http://es-cn-n6w1o1x0w001c****.public.elasticsearch.aliyuncs.com:9200",
"username" : "elastic",
"password" : "xxxxxx",
"index" : "default",
"type" : "default"
},
"sinkCluster":{
"dataSourceType":"elasticsearch",
"username" : "elastic",
"password" : "xxxxxx",
"index" : "default",
"type" : "default",
"settings" : "{\n \"index\": {\n \"replication\": {\n \"type\": .....}",
"mapping" : "{\"doc\":{\"properties\":{\"interval_ms\":{\"type\":\"long\"},....}",
"routing" : "_id"
},
"migrateConfig":{
"sourceFilterParams": "index = 1"
}
} ]
Sample success response
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "5FFD9ED4-C2EC-4E89-B22B-1ACB6FE1****",
"Result" : [ {
"sourceCluster" : {
"password" : "xxxxxx",
"endpoint" : "http://10.20.xx.xx:9200",
"vpcId" : "vpc-2ze55voww95g82gak****",
"vpcInstancePort" : 9200,
"index" : "index_001",
"type" : "index_001",
"vpcInstanceId" : "es-cn-oew1oxiro000f****-worker",
"dataSourceType" : "elasticsearch",
"username" : "elastic"
},
"sinkCluster" : {
"routing" : "cluster_name",
"settings" : "{\\n \\\"index\\\": {\\n \\\"replication\\\": {\\n \\\"type\\\": .....}",
"password" : "xxxxx",
"mapping" : "{\\\"doc\\\":{\\\"properties\\\":{\\\"interval_ms\\\":{\\\"type\\\":\\\"long\\\"},....}",
"vpcInstancePort" : 9200,
"vpcId" : "vpc-2ze55voww95g82gak****",
"index" : "index_001",
"type" : "index_001",
"vpcInstanceId" : "es-cn-oew1oxiro000f****-worker",
"dataSourceType" : "elasticsearch",
"username" : "elastic"
}
} ]
}
Error codes
For a list of error codes, see Service error codes.