elasticsearch索引模板
生活随笔
收集整理的這篇文章主要介紹了
elasticsearch索引模板
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
創建索引模板
索引模板就是創建好一個索引參數設置(settings)和映射(mapping)的模板,在創建新索引的時候指定模板名稱就可以使用模板定義好的參數設置和映射。例如:
PUT _template/mytemplate {"index_patterns": "mylog*","settings": {"number_of_shards": 5,"number_of_replicas": 2},"mappings": {"type": {"properties": {"name": {"type": "keyword"},"age": {"type": "keyword"}}}} }模板名稱是mytemplate,定義好模板可以使用mylog*來適配,分片數量5,副本數量2,默認文檔類型是type
刪除模板
DELETE _template/mytemplate獲取模板
得到所有的模板:GET _template/
使用通配符或逗號分割:GET _template/my*
使用模板
當在添加數據時,指定索引名匹配index_patterns時,ES就會自動為數據新建一個索引。
總結
以上是生活随笔為你收集整理的elasticsearch索引模板的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Elasticsearch索引分析
- 下一篇: Elasticsearch原理与调优