弹性搜索模板

ElasticSearch Templates

我是 运行 ElasticSearch Ubuntu 14.04,我似乎无法让 ES 找到特定索引的模板。该文档令人困惑,因为它说您应该将模板目录放在 /etc/elasticsearch/config/ 下,但随后在文档中它说配置应该在 /etc/elasticsearch 下,就像 yaml 文件位于/etc/elasticsearch.

我知道找不到它的原因是我可以做一个:

curl -XGET 'http://localhost:9200/_template/my_template?pretty'

并返回一个空的 JSON 对象。

根据模板的 config 注释:

Index templates can also be placed within the config location (path.conf) under the templates directory (note, make sure to place them on all master eligible nodes).

在您的情况下,如果您的主要配置目录是 /etc/elasticsearch,那么您可以将模板放在名为 /etc/elasticsearch/templates 的文件夹中。您需要将该文件放置到所有 运行 符合主节点条件的服务器上。 (例如,对于小型集群,在所有节点上。)

根据我的经验,使用 HTTP API 简单 POST 模板更为常见。这样您就可以添加和删除模板,而不必担心在您的服务器上管理和部署配置。

Index Templates