[译] Elasticsearch 索引模板

原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-templates.html


基本配置:

# Don't Check shard when startup
index.shard.check_on_startup : false

# Enabled automatic mapping creation
index.mapper.dynamic : true

# Enabled automatic index creation
action.auto_create_index : true

问题描述:
Elasticsearch 中 _ string _ 型字段默认是_ analyzed _,我们需要根据业务需求,将某些字段设为 _ not_analyzed _。


Elasticsearch 索引模板介绍:
索引模板可以在新建索引后,自动将模板配置信息应用到指定的索引上。模板由_ template _, _ settings _, _ mappings _, _ aliases _ 等构成。通过** template ** 属性(支持简单的规则匹配)来控制该模板将应用到哪些索引上。** template只在索引创建时使用,修改模板不影响已存在的数据。**

由此可见,Elasticsearch 索引模板可以解决上述问题。


示例:

PUT /_template/template_1 
{ 
  "template": "te*", 
  "settings": { 
    "number_of_shards": 1 
  }, 
  "mappings": { 
    "type1": { 
      "_source": { 
        "enabled": false 
    }, 
    "properties": { 
      "host_name": { 
        "type": "string", 
        "index": "not_analyzed" 
      }
    } 
  } 
}

示例解释:
1、模板名:template_1
2、匹配规则:te*,即te开头的索引会使用此模板;
3、示例中将type1 的 host_name (_ string _ )设为 _ not_analyzed _。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,993评论 19 139
  • 获取索引的mapping 实例: 测试分析器 创建一个索引 到目前为止, 我们已经通过索引一篇文档创建了一个新的索...
    M醉逍遥阅读 1,069评论 0 1
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,973评论 6 342
  • 作者:乔生不羁 她是一个平凡的姑娘,没有精致的面容,没有诱人的身材,没有聪明的头脑,却有一颗高傲的心。 他是一个成...
    乔生不羁阅读 1,649评论 10 4
  • 去媳妇家见了未来的岳母岳父和以后的亲戚,紧张,不敢说话,汗不停 从头倆星期的忐忑到头一天的不安到下车那一刻的...
    我要不停的奔跑阅读 234评论 0 0