Skip to main content

ES 别名索引

设置别名索引 alias index

设置别名索引的好处是程序可以只读某个固定的索引名, 但是背后真实的索引可以支持删除和变更.


# 创建索引
# 分片和副本数量根据实际情况配置

curl -L -X PUT 'es.domain.com:15009/ds-audit-operation-log-v1' -H 'Content-Type: application/json' --useruser:password --data '{"settings": {"number_of_shards": 1,"number_of_replicas": 0},"mappings": {"properties": {"TenantId": { "type": "keyword" },"ProjectId": { "type": "keyword", "null_value": "NULL" },"ClusterId": { "type": "keyword" },"ModuleName": { "type": "keyword" },"OperationTime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss"},"OperationUserId": { "type": "keyword" },"OperationUserName": { "type": "keyword" },"OperationObject": { "type": "keyword" },"OperationType": { "type": "keyword" },"OperationStatus": { "type": "keyword" },"Details": {"type": "text"}}}}'


# 创建索引别名
curl -L -X PUT 'es.domain.com:15009/ds-audit-operation-log-v1/_alias/ds-audit-operation-log' --useruser:password