简体   繁体   English

Elasticsearch从文件获取索引映射

[英]Elasticsearch Get Index Mapping from a File

I am looking a way of having index mapping in a file so that it should be loaded when the elasticsearch is starting. 我正在寻找一种在文件中具有索引映射的方法,以便在Elasticsearch启动时应加载它。 Elstic documentation explains how to get so that using a rest call. Elstic文档解释了如何使用rest调用。 I know that index mapping template can be use to set a mapping before creating the index. 我知道可以使用索引映射模板在创建索引之前设置映射。 Anyone can help me how to read the index mappings from a file? 任何人都可以帮助我如何从文件中读取索引映射?

I will store the mapping details in a text file and then I want to upload the file to the elastic search. 我将映射详细信息存储在一个文本文件中,然后将文件上传到弹性搜索。

if you write your own filters for any index you need to create a mapping template. 如果您为任何索引编写自己的过滤器,则需要创建映射模板。 logstash has many dynamic options so can map many fields by default. logstash具有许多动态选项,因此默认情况下可以映射许多字段。

but please ask your question more clear. 但请问清楚您的问题。 what do you mean by reading from file ? 从文件中读取是什么意思? in kibana console you can see the mappings for any index. 在kibana控制台中,您可以看到任何索引的映射。

  1. open kibana 打开木片
  2. go to development tools 转到开发工具
  3. type in console : GET /index/_mapping 在控制台中输入:GET / index / _mapping

for example if you wanna see all indices for logstash pattern , type : GET /logstash-*/_mapping 例如,如果您想查看logstash模式的所有索引,请输入: GET / logstash-* / _ mapping

note : you can see the full mapping template like : GET /_template/logstash 注意 :您可以看到完整的映射模板,例如: GET / _template / logstash

note : for loading your template to elasticsearch type : curl -XPUT -H 'Content-Type:application/json' http://localhost:9200/_template/test -d@test.template.json 注意:用于将模板加载到elasticsearch类型: curl -XPUT -H'Content-Type:application / json'http:// localhost:9200 / _template / test -d@test.template.json

which "test" is your template name and "test.template.json" is your file. 哪个“ test”是您的模板名称,哪个“ test.template.json”是您的文件。

hope this helps and rate if that helped. 希望这会有所帮助,并对其进行评分。 thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM