更新Elasticsearch模板

时间:2018-07-19 11:48:26

标签: elasticsearch logstash

我对Elasticsearch的索引模板有一个小问题。

这是我的模板:

curl -X GET "localhost:9200/_cat/templates?v&s=name"
logstash                      [logstash-*]               0          60001
logstash-index-template       [.logstash]                0

logstash-index-template:

curl -X GET "localhost:9200/_template/logstash-index-template"
{"logstash-index-template":{"order":0,"index_patterns":[".logstash"],"settings":{"index":{"number_of_shards":"1","auto_expand_replicas":"0-1","codec":"best_compression"}},"mappings":{"doc":{"_meta":{"logstash-version":"6.3.1"},"dynamic":"strict","properties":{"description":{"type":"text"},"last_modified":{"type":"date"},"pipeline_metadata":{"properties":{"version":{"type":"short"},"type":{"type":"keyword"}}},"pipeline":{"type":"text"},"pipeline_settings":{"dynamic":false,"type":"object"},"username":{"type":"keyword"},"metadata":{"type":"object","dynamic":false}}}},"aliases":{}}}

我想更新此模板,以便删除auto_expand_replicas并添加number_of_replicas:0。

curl -X PUT "localhost:9200/_template/logstash-index-template" -H 'Content-Type: application/json' -d '{"logstash-index-template":{"order":0,"index_patterns":[".logstash"],"settings":{"index":{"number_of_shards":"1","number_of_replicas":"0","codec":"best_compression"}},"mappings":{"doc":{"_meta":{"logstash-version":"6.3.1"},"dynamic":"strict","properties":{"description":{"type":"text"},"last_modified":{"type":"date"},"pipeline_metadata":{"properties":{"version":{"type":"short"},"type":{"type":"keyword"}}},"pipeline":{"type":"text"},"pipeline_settings":{"dynamic":false,"type":"object"},"username":{"type":"keyword"},"metadata":{"type":"object","dynamic":false}}}},"aliases":{}}}'

这是个好方法吗? 我已经通过此调用更新了现有索引:

curl -X PUT "localhost:9200/_settings" -H 'Content-Type: application/json' -d'{    "index" : {        "number_of_replicas" :0    }}'

我在Elasticsearch网站上找不到完整的文档,因此如果有人已经做过,请在这里询问:)

谢谢,祝您有美好的一天!

0 个答案:

没有答案