是借助索引设计层面在 setting 中关联 default_pipeline 实现的。
实现方式相对简单,能保证用户在设置索引的前提下,用户只关注写入数据,其他后台预处理管道帮助实现细节。
引申一下,针对开篇提到的第二个问题:
- create_time 借助 pipeline 管道预处理 set processor 实现即可。
PUT _ingest/pipeline/create_time_pipeline
{
“description”: “Adds create_time timestamp to documents”,
“processors”: [
{
“set”: {
“field”: “_source.create_time”,
“value”: “{ {_ingest.timestamp}}”
}
}
]
}
DELETE my_index_0003
PUT my_index_0003
{
“settings”: {
“index.default_pipeline”: “create_time_pipeline”
}
}
POST my_index_0003/_doc/1
{}
GET my_index_0003/_search
- update_time 自己维护更新,业务更新的时刻通过代码或者脚本加上时间戳就可以。
3.2 方案 二:update_by_query 通过更新添加默认值
POST customer/_doc/2
{