Elasticsearch - 如何批量插入索引+将索引添加到别名?
Elasticsearch - how to bulk insert index + add index to alias?
我有一个脚本可以创建使用 _bulk API 定期生成的索引。例如,它将创建以下内容:
/foo_2017-06-01/bar/abcd
/foo_2017-05-31/bar/efgh
....
但我想要一个别名,基本上可以为所有这些索引以及更新的索引编制索引。例如我想要:
/foo --> [/foo_2017-06-01, /foo_2017-05-31, ...]
这可能吗?或者我可以做些什么来达到同样的目的?
您可以使用模板来执行此操作:
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-templates.html
模板允许您自动将设置应用到新创建的索引。例如,以下模板将应用于所有带有 'foo_' 前缀的索引,并将其添加到 foo 别名中。
PUT _template/template_1
{
"template" : "foo_*",
"settings" : {
"number_of_shards" : 1
},
"aliases" : {,
"foo" : {}
}
}
我有一个脚本可以创建使用 _bulk API 定期生成的索引。例如,它将创建以下内容:
/foo_2017-06-01/bar/abcd
/foo_2017-05-31/bar/efgh
....
但我想要一个别名,基本上可以为所有这些索引以及更新的索引编制索引。例如我想要:
/foo --> [/foo_2017-06-01, /foo_2017-05-31, ...]
这可能吗?或者我可以做些什么来达到同样的目的?
您可以使用模板来执行此操作: https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-templates.html
模板允许您自动将设置应用到新创建的索引。例如,以下模板将应用于所有带有 'foo_' 前缀的索引,并将其添加到 foo 别名中。
PUT _template/template_1
{
"template" : "foo_*",
"settings" : {
"number_of_shards" : 1
},
"aliases" : {,
"foo" : {}
}
}