# 為文檔添加創(chuàng)建時(shí)間字段管道
PUT _ingest/pipeline/create_time-pipeline
{
"description": "文檔創(chuàng)建時(shí)間",
"processors": [
{
"set": {
"field": "create_time",
"value": "{{_ingest.timestamp}}"
}
}
]
}
## 創(chuàng)建名稱(chēng)為wechat_msg-template的索引模板
PUT _template/wechat_msg-template
{
"index_patterns": "wechat_msg-*",
"order": 1,
"settings": {
"index.number_of_shards": 5,
"index.number_of_replicas": 2,
"index.mapping.coerce": false,
"default_pipeline": "create_time_pipeline", ## 為索引指定默認(rèn)管道
"analysis": {
"analyzer": {
"comma": {
"type": "pattern",
"pattern": ","
}
}
}
},
"mappings": {
"dynamic":"strict",
"properties": {
"create_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||date_optional_time"
},
"update_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||date_optional_time"
},
"app_id": {
"type": "keyword"
},
"original_id": {
"type": "keyword"
},
"open_id": {
"type": "keyword"
},
"nick_name": {
"type": "text",
"fields":{
"full":{
"type": "keyword"
}
}
},
"record_type": {
"type": "keyword"
},
"reply_type":{
"type": "keyword"
},
"message_type": {
"type": "keyword"
},
"event_type":{
"type": "keyword"
},
"event_key":{
"type": "keyword"
},
"is_read": {
"type": "boolean",
"null_value": false
},
"send_code": {
"type": "integer"
},
"err_msg": {
"type": "text"
},
"msg_id": {
"type": "long"
},
"mass_id":{
"type": "long"
},
"message_data": {
"type": "text"
}
}
},
"aliases": {
"wechat_msg": {},
"wechat_msg_all": {}
}
}
## 重建索引,并重命名字段名稱(chēng)
POST _reindex
{
"source": {
"index": "wechat_msg-2021.10"
},
"dest": {
"index": "wechat_msg-2021.10.back"
},
"script": {
"inline": "ctx._source.subscribe_task_id = ctx._source.remove('subscribe_fans_task_id');
ctx._source.interactive_type = ctx._source.remove('activity_type');"
}
}
## 添加字段
PUT wechat_msg-2021.11/_mapping
{
"properties": {
"id": {
"type": "keyword"
}
}
}
## 給新添加的字段賦值
POST wechat_msg/_update_by_query
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "id"
}
}
]
}
},
"script": {
"source": "ctx._source['id'] = ctx._id"
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。