文档

CreateIndexTemplate

更新时间:

调用CreateIndexTemplate,创建集群索引模板,可用于索引模版的组件化设置。仅适用于日志增强版实例。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求头

该接口使用公共请求头,无特殊请求头。请参见公共请求参数文档。

请求语法

POST /openapi/instances/{InstanceId}/index-templates HTTP/1.1

请求参数

名称

类型

位置

是否必选

示例值

描述

InstanceId String Path es-cn-n6w24n9u900am****

实例ID。

ClientToken String Query E1136AE9-4E49-4585-9358-6FDD2A6D****

用于保证请求的幂等性。由客户端生成该参数值,要保证在不同请求间唯一,最大不超过64个ASCII字符。

Object Body

请求体参数,用来指定待创建的集群索引模板的信息。

indexTemplate String Body index-template

索引模版名称。

indexPatterns Array of String Body ["schema1*","schema2*"]

索引匹配模式正则。

dataStream Boolean Body false

是否开启数据流。可选值:

  • true:开启
  • false(默认):不开启
priority Integer Body 30

集群索引模板的优先级。值越大,优先级越高。

ilmPolicy String Body policy-1

生命周期策略名称。

template Object Body

模版设置,详细信息请参见官方Multiple Component Templates文档

settings String Body {\"index.number_of_shards\":\"1\"}

settings设置。

mappings String Body {\"properties\":{\"created_at\":{\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\",\"type\":\"date\"},\"host_name\":{\"type\":\"keyword\"}}}

mappings设置。

aliases String Body {\"mydata\":{}}

aliases设置。

返回数据

名称

类型

示例值

描述

Result String index-template

返回创建集群索引模板的名称。

RequestId String F99407AB-2FA9-489E-A259-40CF6DCC****

请求ID。

示例

请求示例

POST /openapi/instances/es-cn-n6w24n9u900am****/index-templates?ClientToken=E1136AE9-4E49-4585-9358-6FDD2A6D**** HTTP/1.1
Host:elasticsearch.aliyuncs.com
Content-Type:application/json

{
    "indexTemplate": "index-template", 
    "indexPatterns": [
        "schema1*", 
        "schema2*"
    ], 
    "dataStream": true, 
    "priority": 30, 
    "ilmPolicy": "policy-1", 
    "template": {
        "settings": "{\"index.number_of_shards\":\"1\"}", 
        "mappings": "{\"properties\":{\"created_at\":{\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\",\"type\":\"date\"},\"host_name\":{\"type\":\"keyword\"}}}", 
        "aliases": "{\"mydata\":{}}"
    }
}

正常返回示例

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "F99407AB-2FA9-489E-A259-40CF6DCC****",
  "Result" : "index-template"
}

错误码

访问错误中心查看更多错误码。

  • 本页导读 (1)
文档反馈