Docker容器的默认elasticsearchconfiguration

在Docker容器中configuration映射ES索引模板的最佳方法是什么? 我期望使用模板文件,但似乎从版本2 是不可能的 。 执行http请求也不会工作,因为在容器创build过程不启动。 它可以在每个容器启动脚本,将启动ES并执行HTTP请求,但它看起来非常丑陋。

您可以在Linuxterminal中通过执行HTTP PUT请求来configuration具有映射的模板,如下所示:

curl -XPUT http://ip:port/_template/logstash -d ' { "template": "logstash-*", "settings": { "number_of_replicas": 1, "number_of_shards": 8 }, "mappings": { "_default_": { "_all": { "store": false }, "_source": { "enabled": true, "compress": true }, "properties": { "_id": { "index": "not_analyzed", "type": "string" }, "_type": { "index": "not_analyzed", "type": "string" }, "field1": { "index": "not_analyzed", "type": "string" }, "field2": { "type": "double" }, "field3": { "type": "integer" }, "xy": { "properties": { "x": { "type": "double" }, "y": { "type": "double" } } } } } } } ' 

“logstash- *”是你的索引名,你可以试试看。