转载地址:https://dongbo0737.github.io/2017/06/13/elasticsearch-template/#similar_posts

Elasticsearch索引模板

使用Elasticsearch 存储数据的时候,每个单独的索引,或者一个类型的索引都可能有些自己特殊的属性,这样我们就要使用template了 通过指定指定的模版名字,来定义这个类型的索引多少个分片和副本,哪些字段不需要分词等等 使用*可以模糊匹配索引.

例如: business-* 可以匹配到 business-2017.05.01

business template

  1. {
  2. "order": 0,
  3. "template": "test-business-*",
  4. "settings": {
  5. "index": {
  6. "routing": {
  7. "allocation": {
  8. "require": {
  9. "box_type": "hot"
  10. }
  11. }
  12. },
  13. "refresh_interval": "3s",
  14. "analysis": {
  15. "filter": {
  16. "camel_filter": {
  17. "split_on_numerics": "false",
  18. "type": "word_delimiter",
  19. "stem_english_possessive": "false",
  20. "generate_number_parts": "false",
  21. "protected_words": [
  22. "iPhone",
  23. "WiFi"
  24. ]
  25. }
  26. },
  27. "analyzer": {
  28. "camel_analyzer": {
  29. "filter": [
  30. "camel_filter",
  31. "lowercase"
  32. ],
  33. "char_filter": [
  34. "html_strip"
  35. ],
  36. "type": "custom",
  37. "tokenizer": "ik_smart"
  38. }
  39. },
  40. "tokenizer": {
  41. "my_tokenizer": {
  42. "type": "whitespace",
  43. "enable_lowercase": "false"
  44. }
  45. }
  46. },
  47. "number_of_shards": "30",
  48. "number_of_replicas": "0"
  49. }
  50. },
  51. "mappings": {
  52. "_default_": {
  53. "dynamic_templates": [
  54. {
  55. "message_field": {
  56. "mapping": {
  57. "analyzer": "camel_analyzer",
  58. "index": "analyzed",
  59. "omit_norms": true,
  60. "type": "string"
  61. },
  62. "match_mapping_type": "string",
  63. "match": "message"
  64. }
  65. },
  66. {
  67. "logid_field": {
  68. "mapping": {
  69. "type": "long"
  70. },
  71. "match_mapping_type": "string",
  72. "match": "logid"
  73. }
  74. },
  75. {
  76. "string_fields": {
  77. "mapping": {
  78. "index": "not_analyzed",
  79. "omit_norms": true,
  80. "type": "string",
  81. "fields": {
  82. "raw": {
  83. "ignore_above": 256,
  84. "index": "not_analyzed",
  85. "type": "string"
  86. }
  87. }
  88. },
  89. "match_mapping_type": "string",
  90. "match": "*"
  91. }
  92. }
  93. ],
  94. "_all": {
  95. "omit_norms": true,
  96. "enabled": true
  97. },
  98. "properties": {
  99. "geoip": {
  100. "dynamic": true,
  101. "type": "object",
  102. "properties": {
  103. "location": {
  104. "type": "geo_point"
  105. }
  106. }
  107. },
  108. "@version": {
  109. "index": "not_analyzed",
  110. "type": "string"
  111. }
  112. }
  113. }
  114. },
  115. "aliases": {}
  116. }

webaccess template

  1. {
  2. "order": 0,
  3. "template": "test-webaccess-*",
  4. "settings": {
  5. "index": {
  6. "routing": {
  7. "allocation": {
  8. "require": {
  9. "box_type": "hot"
  10. }
  11. }
  12. },
  13. "refresh_interval": "3s",
  14. "analysis": {
  15. "analyzer": {
  16. "ik": {
  17. "type": "custom",
  18. "tokenizer": "ik_smart"
  19. }
  20. }
  21. },
  22. "number_of_shards": "20",
  23. "number_of_replicas": "0"
  24. }
  25. },
  26. "mappings": {
  27. "_default_": {
  28. "dynamic_templates": [
  29. {
  30. "message_field": {
  31. "mapping": {
  32. "analyzer": "ik",
  33. "index": "analyzed",
  34. "omit_norms": true,
  35. "type": "string"
  36. },
  37. "match_mapping_type": "string",
  38. "match": "message"
  39. }
  40. },
  41. {
  42. "bytes_field": {
  43. "mapping": {
  44. "type": "long"
  45. },
  46. "match_mapping_type": "string",
  47. "match": "bytes"
  48. }
  49. },
  50. {
  51. "string_fields": {
  52. "mapping": {
  53. "index": "not_analyzed",
  54. "omit_norms": true,
  55. "type": "string",
  56. "fields": {
  57. "raw": {
  58. "ignore_above": 256,
  59. "index": "not_analyzed",
  60. "type": "string"
  61. }
  62. }
  63. },
  64. "match_mapping_type": "string",
  65. "match": "*"
  66. }
  67. }
  68. ],
  69. "_all": {
  70. "omit_norms": true,
  71. "enabled": true
  72. },
  73. "properties": {
  74. "geoip": {
  75. "dynamic": true,
  76. "type": "object",
  77. "properties": {
  78. "location": {
  79. "type": "geo_point"
  80. }
  81. }
  82. },
  83. "@version": {
  84. "index": "not_analyzed",
  85. "type": "string"
  86. }
  87. }
  88. }
  89. },
  90. "aliases": {}
  91. }

Similar Posts

Elasticsearch索引模板-转载的更多相关文章

  1. ElasticStack学习(八):ElasticSearch索引模板与聚合分析初探

    一.Index Template与Dynamic Template的概念 1.Index Template:它是用来根据提前设定的Mappings和Settings,并按照一定的规则,自动匹配到新创建 ...

  2. Elasticsearch索引模板和别名

    创建模板(模板名和索引名一样都不能有大写) PUT http://222.108.x.x:9200/_template/templateds { "template": " ...

  3. ES 10 - Elasticsearch的索引别名和索引模板

    目录 1 索引模板概述 1.1 什么是索引模板 1.2 索引模板中的内容 1.3 索引模板的用途 2 创建索引模板 3 查看索引模板 4 删除索引模板 5 模板的使用建议 5.1 一个index中不能 ...

  4. Elasticsearch之索引模板index template与索引别名index alias

    为什么需要索引模板? 在实际工作中针对一批大量数据存储的时候需要使用多个索引库,如果手工指定每个索引库的配置信息(settings和mappings)的话就很麻烦了. 所以,这个时候,就存在创建索引模 ...

  5. elasticsearch 5.x 系列之四(索引模板的使用,详细得不要不要的)

    1,首先看一下下面这个索引模板 curl -XPUT "master:9200/_template/template_1?pretty" -H 'Content-Type: app ...

  6. ElasticSearch(六):索引模板

    ElasticSearch(六):索引模板 学习课程链接<Elasticsearch核心技术与实战> Index Template Index Template - 帮助你设定Mappin ...

  7. Elasticsearch学习笔记——索引模板

    在索引模板里面,date类型的字段的format支持多种类型,在es中全部会转换成long类型进行存储,参考 https://zhuanlan.zhihu.com/p/34240906 一个索引模板范 ...

  8. Elasticsearch入门教程(三):Elasticsearch索引&映射

    原文:Elasticsearch入门教程(三):Elasticsearch索引&映射 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文 ...

  9. Elasticsearch7.X 入门学习第八课笔记-----索引模板和动态模板

    原文:Elasticsearch7.X 入门学习第八课笔记-----索引模板和动态模板 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接: ...

随机推荐

  1. onsen & UI & vue & mobile UI

    onsen & UI vue & mobile UI $ npm i onsenui vue-onsenui # OR $ npm i -S onsenui vue-onsenui h ...

  2. js 位掩码

    原文 定义掩码 const mask0 = parseInt("00000001", 2); const mask1 = parseInt("00000010" ...

  3. 双十一NGK官方快讯!

  4. 如何在数据库中进行RBAC权限应用

    上周我们发了一篇关于"删库跑路"引发了大家对于数据安全的思考,而权限管理又跟数据安全密不可分.权限管理作为数据系统的重要组成部分,通过控制账号的可支配能力,防止因用户操作不当导致的 ...

  5. K8S部署Redis Cluster集群(三主三从模式) - 部署笔记

    一.Redis 介绍 Redis代表REmote DIctionary Server是一种开源的内存中数据存储,通常用作数据库,缓存或消息代理.它可以存储和操作高级数据类型,例如列表,地图,集合和排序 ...

  6. pytorch中修改后的模型如何加载预训练模型

    问题描述 简单来说,比如你要加载一个vgg16模型,但是你自己需要的网络结构并不是原本的vgg16网络,可能你删掉某些层,可能你改掉某些层,这时你去加载预训练模型,就会报错,错误原因就是你的模型和原本 ...

  7. vue路由理解

    vue路由:就是一个菜单的概念比如说有一个菜单栏,菜单栏上有很多按钮,当你点击一个按钮时会出现不同的页面,这就是vue路由

  8. Python学习相关链接

    感觉挺全的: http://www.cnblogs.com/xinshiye/p/9015187.html 也挺全的:http://www.cnblogs.com/toutou/category/72 ...

  9. Vue学习笔记-rest_framework_jwt 学习

    一  使用环境 开发系统: windows 后端IDE: PyCharm 前端IDE: VSCode 数据库: msyql,navicat 编程语言: python3.7  (Windows x86- ...

  10. SpringBoot2.x中的AOP机制总结(附带demo)

    寄语:刚开始学aop的时候是大三吧,老师讲的不好,我也没学好,导致现在才有个较为清晰的认知,那个时候只知道有aop, 根部不明白aop的作用,时至今日,任然觉得aop难以咀嚼,奈何平时不用面试要用,特 ...