随着业务的发展,这是一个很常见的需求
参考资料: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