基于Elasticsearch文件的索引模板未显示在"/_template"中API调用 [英] Elasticsearch file-based index templates not showing up in "/_template" API call
问题描述
我试图在Elasticsearch中自动使用索引模板,因此我开始在"[ES_CONFIG_DIR]/templates/"目录中创建文件( http://pastebin.com/waKCBGgW ).我的厨师食谱执行以下步骤:
I'm attempting to automate the usage of index templates in Elasticsearch, so I've started creating the files in the "[ES_CONFIG_DIR]/templates/" directory (http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#config) with the proper format (sample file: http://pastebin.com/waKCBGgW). My Chef cookbook performs the following steps:
1.在"[ES_CONFIG_DIR]/templates/tpl_misc.json"目录中创建JSON模板文件 2.重新启动elasticsearch服务
1.Create the JSON template file in the "[ES_CONFIG_DIR]/templates/tpl_misc.json" directory 2.Restart the elasticsearch service
完成此操作的厨师代码块是:
The block of chef code to complete this is:
相关属性:
default['elasticsearch']['index_templates'] = [
"tpl_misc"
]
相关食谱代码:
directory "#{node['elasticsearch']['path']['conf']}/templates" do
owner 'elasticsearch'
group 'elasticsearch'
mode '0755'
action :create
end
node['elasticsearch']['index_templates'].each do |tpl|
template "#{node['elasticsearch']['path']['conf']}/templates/#{tpl}.json" do
source "#{tpl}.erb"
owner 'elasticsearch'
group 'elasticsearch'
mode '0644'
notifies :restart, 'service[elasticsearch]'
end
end
我可以确认模板文件已在应放置的位置(在/usr/local/etc/elasticsearch/templates中)创建,尽管当我检查ES中是否存在模板时(curl -iL
I can confirm the template files are being created where they should (in /usr/local/etc/elasticsearch/templates) although when I check to see exists in ES (curl -iL http://localhost:9200/_template/tpl_misc) and i always get a 404. Does anyone have any advice on what my issue might be?
感谢您的帮助!
推荐答案
我了解到,作为文件添加到"[CONFIG]/templates/"目录中的索引模板当前未出现在的结果中"/_template/" * API方法.有人在以下电子邮件线程中提到了这一点:
I've learned that index templates added as files in the "[CONFIG]/templates/" directory do not currently appear in the results of the "/_template/"* API method. Someone refers to that in the following email thread:
尽管未在官方索引模板中进行记录文档在Elasticsearch网站上.从那以后,我创建了一个拉动请求以更新文档,这也导致了一个问题正在打开,以便将功能添加到"/_template/" API方法中
Although it was not documented in the official index templates documentation on the Elasticsearch website. I've since then created a pull request to have the documentation updated which has also lead to an issue being opened in order to have ability added to the "/_template/" API method.
这篇关于基于Elasticsearch文件的索引模板未显示在"/_template"中API调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!