创建生命周期策略,并指定索引文档数量为10时创建新的索引:
PUT _ilm/policy/roll-policy-10
{
"policy": {
"phases": {
"hot": {
"min_age": "0s",
"actions": {
"rollover": {
"max_docs": 10
},
"set_priority": {
"priority": 100
}
}
}
}
}
}
创建一个索引,并将索引与生命周期策略关联:
PUT /roll-000001
{
"settings": {
"index":{
"lifecycle": {
"name": "roll-policy",
"rollover_alias" : "roll-alias"
}
}
},
"aliases": {
"roll-alias": {
"is_write_index": true
}
}
}
创建后,往索引里插入一定数量的文档,将会自动创建roll-000002索引,但是据笔者观察,不一定十分及时。
如果想用Java elasticseach client创建生命周期策略(不常用,一般不由开发创建):
IlmPolicy ilmPolicy = IlmPolicy.of(a -> a.phases(b -> b.hot(c -> c.actions(null))));
PutLifecycleRequest putLifecycleRequest = PutLifecycleRequest.of(a -> a.name("").policy(ilmPolicy));
client.ilm().putLifecycle(putLifecycleRequest);
标签:生命周期,alias,创建,索引,DSL,Elasticsearch,policy,Query,roll From: https://www.cnblogs.com/JackieJK/p/18520995