我们在做es搜索的场合,每次创建索引的时候,都需要为每个索引设置mapping的字段映射,现在我们可以为通用的索引创建一个模板

每次创建索引时候,如果匹配到相应的模板 索引的mapping会被自动设置成模板的mapping配置

PUT  _template/temp_test
{
"index_patterns": ["market*", "car*"],//匹配规则
"settings": {
"index.number_of_shards" : 5, //分片数
"number_of_shards": 1 //数据副本
},
"mappings": {
"goods": {//索引类型
"dynamic_templates": [
{
"dynamicFields": {//动态字段
"match_mapping_type": "string",//动态字段匹配类型
"path_match":"dynamicFields.*_sku_attr",//匹配规则
"mapping":{
"type": "keyword" //匹配的字段的类型映射
}
}
}
],
"properties":{ //普通字段的类型设置
"id":{
"type": "keyword"
},
"category_first_id":{
"type": "keyword"
},
"category_first":{
"type": "keyword"
},
"category_second_id":{
"type": "keyword"
},
"category_second":{
"type": "keyword"
},
"category_third_id":{
"type": "keyword"
},
"category_third":{
"type": "keyword"
},
"brand_id":{
"type": "keyword"
},
"brand":{
"type": "text",
"analyzer":"ik_max_word",
"search_analyzer":"ik_max_word",
"copy_to":"full_name"
},
"shop":{
"type": "keyword"
},
"attr_name":{
"type": "keyword",
"index":"true" },
"sku":{
"type": "keyword",
"index":"true"
},
"spu":{
"type": "keyword",
"index":"true"
},
"gome_sku":{
"type": "keyword"
},
"product_ch":{
"type": "text",
"analyzer":"ik_max_word",
"search_analyzer":"ik_max_word",
"copy_to":"full_name"
},
"adver":{
"type": "keyword"
},
"product_img":{
"type": "keyword"
},
"product_proto_price":{
"type": "double"
},
"product_sale_price":{
"type": "double"
},
"is_sku":{
"type": "boolean"
},
"is_self":{
"type": "boolean"
},
"shop_flag":{
"type": "long"
},
"is_in_store":{
"type": "boolean"
},
"is_shelves":{
"type": "boolean"
},
"is_suit":{
"type": "boolean"
},
"good_comment_rate":{
"type": "long"
},
"sale_num":{
"type": "long"
},
"spu_score":{
"type": "long"
},
"dynamic_attrs":{
"type": "keyword"
},
"full_name":{
"type": "text",
"store":"true"
},
"create_time":{
"type":"date"
}
}
}
}
}

ElasticSearch6.0 索引模板的更多相关文章

  1. ElasticSearch6.0 Java API 使用 排序,分组 ,创建索引,添加索引数据,打分等(一)

    ElasticSearch6.0  Java API  使用     排序,分组 ,创建索引,添加索引数据,打分等 如果此文章对你有帮助,请关注一下哦 1.1 搭建maven 工程  创建web工程 ...

  2. ElasticSearch6.0 高级应用之 多字段聚合Aggregation(二)

    ElasticSearch6.0 多字段聚合网上完整的资料很少 ,所以作者经过查阅资料,编写了聚合高级使用例子 例子是根据电商搜索实际场景模拟出来的 希望给大家带来帮助! 下面我们开始吧! 1. 创建 ...

  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. ElasticStack学习(八):ElasticSearch索引模板与聚合分析初探

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

  7. ElasticSearch(六):索引模板

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

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

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

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

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

随机推荐

  1. loadrunner配置多台负载机设置

    面对并发量比较大的性能需求,用单台机子进行加压由于本身硬件资源.网络资源等的限制已经不能满足该性能测试条件,这个时候就需要在场景中添加多台负载机来联机做性能测试.添加多台负载机的设置非常简单下面做一个 ...

  2. jvm3---垃圾回收器算法

    .1. GC算法 .1.1. 标记-清除算法(Mark-Sweep) 1.标记出所有需要回收的对象,在标记完成后统一回收所有被标记的对象 2.在标记完成后统一回收所有被标记的对象 缺点:一个是效率问题 ...

  3. Activiti工作流引擎数据库表结构

    Activiti工作流引擎数据库表结构 一.数据库表的命名 Acitiviti数据库中表的命名都是以ACT_开头的.第二部分是一个两个字符用例表的标识.此用例大体与服务API是匹配的. ACT_RE_ ...

  4. wget指定目录下载以及其它的使用方式

    转自 http://java-er.com/blog/wget-useage-x/ 有时候我们需要wget一个文件下载到指定的目录下,或者重命名成指定的名字 wget -r -p -np -k -P ...

  5. Alluxio集成Hadoop

    准备工作 为了运行Alluxio集群在多个机器上,必须部署Alluxio服务到这些机器上.可以下载伴随特定Hadoop版本的二进制AlLxio包,也可以从Alluxio源码中编译. 当从源码中编译时, ...

  6. 【论文解析】MTCNN论文要点翻译

    目录 0.论文连接 1.前言 2.论文Abstract翻译 3.论文的主要贡献 4.4 训练 5 模型性能分析 5.1 关于在线挖掘困难样本的性能 5.2 将人脸检测与对齐联合的性能 5.3 人脸检测 ...

  7. spring 及 spring boot 资源文件配置

    Spring配置文件引入xml文件: <import resource=" " />标签使用总结 https://www.cnblogs.com/javahr/p/83 ...

  8. MySQL MVVC

    什么是MVVC? MVVC (Multi-Version Concurrency Control) (注:与MVCC相对的,是基于锁的并发控制,Lock-Based Concurrency Contr ...

  9. 仿照Chome的GhostPage调试功能

    今天在测试过程中发现了网站的一个bug,在大屏幕上是自适应的,小屏幕笔记本上高度不是自适应,html的高度并不是浏览器的高度,小屏幕总是差了一截,在调试过程中偶然发现差的那一小截正好是一个横向滑动条的 ...

  10. SQL Server 的索引结构实例

    目前SQL Server 的索引结构如下: 这个是聚集索引的存放形式: 非聚集索引的方式如下: 它们是以B+树的数据结构存放的. 相信大家都看过类似的图,但是没有直观的认识,下面举一个实际的例子来说明 ...