弹性搜索索引模板中的多个索引

Multiple indices in elastic search Index template

在elasticsearch网站上研究了Indices-templates,明白了。现在我的要求是我想在两个索引上应用相同的模板。 假设我有一个模板文件:template_search.json 并且我希望将此模板应用于两个索引 - index1_、index2_ 所以在这个文件中,我在这个模板文件中定义了模板属性如下:

"template" : "index1_*,index2_*"

但我给出了以下验证错误:

Error uploading template: {"root_cause":[{"type":"invalid_index_template_exception","reason":"index_template [template_search] invalid, cause [Validation Failed: 1: template must not contain a ',';2: template must not container the following characters [\, /, *, ?, \", <, >, |,  , ,];]"}],"type":"invalid_index_template_exception","reason":"index_template [template_search] invalid, cause [Validation Failed: 1: template must not contain a ',';2: template must not container the following characters [\, /, *, ?, \", <, >, |,  , ,];]"}

我知道一种方法,我可以为每个索引创建一个单独的文件。但随后我将拥有两个具有相同数据的不同文件。

我试图在 Whosebug 上搜索它,但没有找到任何可以帮助我解决它的答案。有人知道如何在单个模板文件中定义多个索引吗? 提前致谢。

Elasticsearch 的下一个主要版本 (6.x) 将支持 index_patterns 作为数组来填补这一空白,请参阅 https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html

对于 5.x,您目前无法创建多个模板(或使用 index*)。