我们在做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. JVM年轻代(转)

    本文转自:http://my.oschina.net/xishuixixia/blog/133850 1.为什么会有年轻代 我们先来屡屡,为什么需要把堆分代?不分代不能完成他所做的事情么?其实不分代完 ...

  2. MLlib1.6指南笔记

    MLlib1.6指南笔记 http://spark.apache.org/docs/latest/mllib-guide.html spark.mllib RDD之上的原始API spark.ml M ...

  3. PCLK怎么获得?

    1.PCLK是由MCLK进行分频而来...... 2.PCLK是个时钟,通过寄存器只能调节它的频率什么的,它是控制像素输出的一个时钟: 3.在曝光时间的算法中需要知道PCLK的值,是因为在sensor ...

  4. Django学习笔记之Django Form表单详解

    知识预览 构建一个表单 在Django 中构建一个表单 Django Form 类详解 使用表单模板 回到顶部 构建一个表单 假设你想在你的网站上创建一个简单的表单,以获得用户的名字.你需要类似这样的 ...

  5. The mind

    Youtube励志红人Mateusz M,最近刚推出了网友期待已久最新励志短片<The mind>,短短一周播放量已近50万.来自波兰的他,年仅23岁,用自己擅长的蒙太奇,已创作十几个影响 ...

  6. VirtualBox安装RedHat7

    软件准备 VirtualBox-5.2.8-121009-Win.exe rhel-server-7.4-x86_64-dvd.iso 安装环境 win10 安装步骤: 1.先在win10系统中安装V ...

  7. jsp判断以某个字母开头

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ tag ...

  8. LeetCode——Median of Two Sorted Arrays

    Question There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median o ...

  9. storm(一) window机制

    Watermark作用 在解释storm的window之前先说明一下watermark原理. Watermark中文翻译为水位线更为恰当. 顺序的数据从源头开始发送到到操作,中间过程肯定会出现数据乱序 ...

  10. 解决github访问慢的问题

    在windows hosts文件末尾增加以下内容 # GitHub Start 192.30.253.112 github.com 192.30.253.119 gist.github.com 151 ...