0

我有以下 ilm (忽略最小年龄,用于测试):

"somerandomilm": {
    "version": 3,
    "modified_date": "2020-04-09T16:09:16.952Z",
    "policy": {
        "phases": {
            "warm": {
                "min_age": "3m",
                "actions": {
                    "allocate": {
                        "include": {
                            "phase_id": "warm"
                        },
                        "exclude": {},
                        "require": {}
                    },
                    "shrink": {
                        "number_of_shards": 1
                    },
                    "forcemerge": {
                        "max_num_segments": 1
                    },
                    "set_priority": {
                        "priority": 25
                    }
                }
            },
            "cold": {
                "min_age": "5m",
                "actions": {
                    "allocate": {
                        "include": {
                            "phase_id": "cold"
                        },
                        "exclude": {},
                        "require": {}
                    },
                    "set_priority": {
                        "priority": 25
                    }
                }
            },
            "hot": {
                "min_age": "0ms",
                "actions": {
                    "rollover": {
                        "max_size": "30gb",
                        "max_age": "3m"
                    },
                    "set_priority": {
                        "priority": 50
                    }
                }
            }
        }
    }
}

和第一个起始索引:

"somerandomindexname-000001": {
    "aliases": {
        "genericrolloveralias": {
            "is_write_index": false
        }
    },
    "mappings": {
        "properties": {
            "Id": {
                "type": "text"
            },
            "SomeOtherProperty": {
                "type": "text"
            },
            "SomeOtherProperty2": {
                "type": "text"
            }
        }
    },
    "settings": {
        "index": {
            "lifecycle": {
                "name": "somerandomilm",
                "rollover_alias": "genericrolloveralias",
                "indexing_complete": "true"
            },
            "routing": {
                "allocation": {
                    "include": {
                        "phase_id": "warm"
                    }
                }
            },
            "number_of_shards": "1",
            "provided_name": "somerandomindexname-000001",
            "creation_date": "1586447619447",
            "priority": "25",
            "number_of_replicas": "1",
            "uuid": "ByKhH8dnR_Sx50GwWNjJaQ",
            "version": {
                "created": "7060099"
            }
        }
    }
}

模板:

    "randomtemplate_template": {
    "order": 0,
    "index_patterns": [
        "somerandomindexname-*"
    ],
    "settings": {
        "index": {
            "lifecycle": {
                "name": "somerandomilm",
                "rollover_alias": "genericrolloveralias"
            },
            "number_of_shards": "1",
            "number_of_replicas": "1"
        }
    },
    "mappings": {},
    "aliases": {}
},

是否可以根据当前移动到的阶段为索引添加额外的别名来获得弹性?

即:当一个索引被移动到温暖的时候,是否所有在温暖的索引都添加了一个额外的别名来指示它处于哪个阶段?我的最终目标是能够查询特定节点,如热/暖,我的理解是这可以通过别名来实现。

4

1 回答 1

0

通过调用 ILM 解释 api 解决了这个问题,该 API 提供了索引列表及其当前阶段是什么。获得列表后,我可以过滤掉任何已移动或正在移动到暖阶段的索引并运行批量别名操作。

var resp = _client.IndexLifecycleManagement.ExplainLifecycleAsync(new ExplainLifecycleRequest(_hotIndexAlias));

var warmPhaseIndices = resp .Indices.Where(i => i.Value.Phase == "warm").ToList();
于 2021-03-15T17:52:04.820 回答