es索引增加字段以及数据备份

随着业务的发展,这是一个很常见的需求

参考资料:https://blog.csdn.net/winterking3/article/details/108242124#7__98

#创建索引,手动指定mapping
PUT /ads_iot_electricity_index2
{
    "mappings": {
        "_doc": {
            "properties": {
                "dh": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "dm": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "dt": {
                    "type": "date"
                },
                "elec_use_cnts": {
                    "type": "float"
                },
                "equipmentNo": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "frequency": {
                    "type": "long"
                },
                "max_dataValue": {
                    "type": "float"
                },
                "meterVarId": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "min_dataValue": {
                    "type": "float"
                },
                "name": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "pk": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "projectIdentify": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                },
                "total_cnts": {
                    "type": "float"
                },
                "type_": {
                    "type": "long"
                },
                "unit": {
                    "fields": {
                        "keyword": {
                            "ignore_above": 256,
                            "type": "keyword"
                        }
                    },
                    "type": "text"
                }
            }
        }
    }
}

从备份索引中恢复数据
POST _reindex
{
"source": {
"index":"ads_iot_electricity_index3",
"_source": {
      "excludes": ["t_start"]
    }
},
"dest": {
"index":"ads_iot_electricity_index2"
}
}

添加字段,执行类型
PUT /ads_iot_electricity_index2/_mapping/_doc
{
    "properties":{
       "t_start":{"type" : "date", "format": "yyyy-MM-dd HH:mm:ss"}
    }
}

查看mapping信息
GET /ads_iot_electricity_index2/_doc/_mapping

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值