調用CreateDataTasks,創建索引遷移任務,將所選集群中的數據遷移到當前集群。

調用該接口前,需要注意:

  • 目前一鍵索引遷移功能僅支持華北2(北京)地域。
  • 源和目標端Elasticsearch集群需要滿足:源端為6.7.0版本的自建或阿里云Elasticsearch集群,目標端為6.3.2或6.7.0版本的阿里云Elasticsearch集群。

調試

您可以在OpenAPI Explorer中直接運行該接口,免去您計算簽名的困擾。運行成功后,OpenAPI Explorer可以自動生成SDK代碼示例。

請求頭

該接口使用公共請求頭,無特殊請求頭。請參見公共請求參數文檔。

請求語法

POST /openapi/instances/{InstanceId}/data-task HTTP/1.1

請求參數

名稱 類型 位置 是否必選 示例值 描述
ClientToken String Query 5A2CFF0E-5718-45B5-9D4D-70B3FF****

用于保證請求的冪等性。由客戶端生成該參數值,要保證在不同請求間唯一,最大不超過64個ASCII字符。

InstanceId String Path es-cn-n6w1o1x0w001c****

索引遷移的目標集群ID。

Array Body

請求體參數。

sourceCluster Object Body

源集群信息。

dataSourceType String Body elasticsearch

源集群類型。默認為elasticsearch。

endpoint String Body http://yourdomain.com

集群公網域名。源集群為開啟公網時可填寫。

vpcInstanceId String Body es-xxx-worker

當前集群的實例ID或負載均衡SLB(Server Load Balancer)實例ID。源集群采用VPC信息進行連接。

username String Body elastic

源集群的登錄用戶名。

password String Body es_password

源集群的登錄密碼。

index String Body index_001

源集群索引。

type String Body index_001

源集群索引的數據類型。

vpcInstancePort Integer Body 9200

訪問集群的端口號。源集群采用VPC信息進行連接。

vpcId String Body vpc-xxx

集群所在的專有網絡ID。源集群采用VPC信息進行連接。

說明 endpoint為公網域名時可不填,為私網域名時需填寫。
sinkCluster Object Body

目標集群信息。

dataSourceType String Body elasticsearch

目標集群類型。

username String Body elastic

目標集群的登錄用戶名。

password String Body xxxxx

目標集群的登錄密碼。

index String Body index_001

目標集群的指定索引。

type String Body index_001

指定索引的類型。

settings String Body {\n \"index\": {\n \"replication\": {\n \"type\": .....}

Settings配置。

mapping String Body {\"doc\":{\"properties\":{\"interval_ms\":{\"type\":\"long\"},....}

Mapping配置。

routing String Body _id

索引路由字段,默認使用主鍵字段。

migrateConfig Object Body

遷移配置。

sourceFilterParams String Body index=111

索引的過濾條件,過濾指定條件的文檔來做索引重建。

  • 集群開啟公網:填寫endpoint參數進行連接。
  • 集群未開啟公網(或使用VPC信息連接集群):填寫參數vpcInstancePort、vpcId、vpcInstanceId或vpcInstancePort、vpcId、vpcIp進行連接。

示例如下:

  • 公網訪問集群
    
        {
            "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 配置#",
                "mapping" : "#mapping配置#",
                "routing" : "_id"
            },
            "migrateConfig": {
                "sourceFilterParams": ""
            }
       }
         
  • 阿里云Elasticsearch集群
    
        {
            "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 配置#",
                "mapping" : "#mapping配置#",
                "routing" : "_id"
            },
            "migrateConfig": {
                "sourceFilterParams": ""
            }
        }
        

返回數據

名稱 類型 示例值 描述
RequestId String 5FFD9ED4-C2EC-4E89-B22B-1ACB6FE1****

請求ID。

Result Array of Result

返回結果。

sourceCluster Object

源集群信息。

password String xxxxxx

源集群的訪問密碼。

index String index_001

指定待遷移的索引。

type String index_001

指定的索引類型。

endpoint String http://10.20.xx.xx:9200

集群公網域名。

username String elastic

源集群的用戶名。

vpcId String vpc-2ze55voww95g82gak****

源集群所在的專有網絡ID(集群訪問地址為公網域名可不填,私網地址需要填寫)。

vpcInstanceId String es-cn-oew1oxiro000f****-worker

專有網絡下集群的實例ID,或SLB實例ID。

vpcInstancePort Integer 9200

源集群的訪問端口號。

dataSourceType String elasticsearch

源集群類型,默認為elasticsearch。

sinkCluster Object

目標集群信息。

password String xxxxx

目標集群的訪問密碼。

index String index_001

目標索引名。

settings String {\n \"index\": {\n \"replication\": {\n \"type\": .....}

Settings配置。

mapping String {\"doc\":{\"properties\":{\"interval_ms\":{\"type\":\"long\"},....}

Mapping配置。

type String index_001

目標索引類型。

routing String cluster_name

路由字段,默認使用主鍵字段。

username String elastic

目標集群的用戶名。

vpcId String vpc-2ze55voww95g82gak****

集群所在的專有網絡ID(集群訪問地址為公網域名可不填,私網地址需要填寫)。

vpcInstancePort String 9200

集群訪問端口號。

vpcInstanceId String es-cn-oew1oxiro000f****-worker

專有網絡下集群的實例ID,或SLB實例ID。

dataSourceType String elasticsearch

目標集群類型。

示例

請求示例

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"
    }
  } ]

正常返回示例

JSON格式

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"
    }
  } ]
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。