首页 > 其他分享 >es定制 dynamic mapping template(type)

es定制 dynamic mapping template(type)

时间:2023-11-19 16:32:46浏览次数:33  
标签:index my dynamic mapping 索引 template type1 index1 type

定制 dynamic mapping template(type)

PUT /my_index { "mappings": { "my_type": { "dynamic_templates": [ { "en": { "match": "*_en", "match_mapping_type": "string", "mapping": { "type": "text", "analyzer": "english" } } } ] } } } #使用了模板

PUT /my_index/my_type/3 { "title_en": "this is my dog"

} #没有使用模板

PUT /my_index/my_type/5 { "title": "this is my cat" }

GET my_index/my_type/_search { "query": { "match": { "title": "is" } } }

3.27重建索引

一个field的设置是不能修改的,如果要修改一个field,那么应该重新按照新的mapping,建立一个index,然后将数据批量查询出来,重新用bulk api写入到index中。

批量查询的时候,建议采用scroll api,并且采用多线程并发的方式来reindex数据,每次scroll就查询指定日期的一段数据,交给一个线程即可。

PUT /index1/type1/4 { "content":"1990-12-12" }

GET /index1/type1/_search

GET /index1/type1/_mapping

#报错 PUT /index1/type1/4 { "content":"I am very happy." }

#修改content的类型为string类型,报错,不允许修改

PUT /index1/_mapping/type1 { "properties": { "content":{ "type": "text" } } }

#创建一个新的索引,把index1索引中的数据查询出来导入到新的索引中 #但是应用程序使用的是之前的索引,为了不用重启应用程序,给index1这个索引起个#别名

PUT /index1/_alias/index2

#创建新的索引,把content的类型改为字符串

PUT /newindex { "mappings": { "type1":{ "properties": { "content":{ "type": "text" } } } } }

#使用scroll批量查询

GET /index1/type1/_search?scroll=1m { "query": { "match_all": {} }, "sort": ["_doc"], "size": 2 }

#使用bulk批量写入新的索引 POST /_bulk {"index":{"_index":"newindex","_type":"type1","_id":1}} {"content":"1982-12-12"}

#将别名index2和新的索引关联,应用程序不用重启

POST /_aliases { "actions": [ {"remove": {"index":"index1","alias":"index2"}}, {"add": {"index": "newindex","alias": "index2"}} ] }

GET index2/type1/_search

3.28 索引不可变的原因

倒排索引包括:

文档的列表,文档的数量,词条在每个文档中出现的次数,出现的位置,每个文档的长度,所有文档的平均长度

索引不变的原因:

不需要锁,提升了并发性能

可以一直保存在缓存中(filter)

节省cpu和io开销

标签:index,my,dynamic,mapping,索引,template,type1,index1,type
From: https://blog.51cto.com/u_16237074/8474246

相关文章

  • C# 22H2之后的windows版本使用SetDynamicTimeZoneInformation设置时区失败处理
    使用SetDynamicTimeZoneInformation设置时区返回false,设置失败。使用PowerShell设置Set-TimeZone成功。///<summary>///设置本地时区///参数取值"ChinaStandardTime",即可设置为中国时区///</summary>///<paramname="timeZoneId"></param>///<retur......
  • asp.net core api 3.1 dynamic 入参转json对象
    比如接口publicobjectGetList(dynamicobj){//varjElement=(JsonElement)obj;//使用system.text.json处理varstr=obj.GetRawText(); if(val!=JsonValueKind.Undefined&&val!=JsonValueKind.Null)           {if(obj.valueKind==JsonValueKind.Array)......
  • 无涯教程-D语言 - 模板(Templates)
    模板是通用编程的基础,它涉及以独立于任何特定类型的方式编写代码。函数模板将函数定义为模板会将其使用的一种或多种类型保留为未指定状态,以便稍后由编译器推导。在模板参数列表中定义了未指定的类型,该参数介于函数名称和函数参数列表之间。因此,函数模板具有两个参数列表-模板......
  • java RestTemplate 发送post请求
    RestTemplate简介RestTemplate是执行HTTP请求的同步阻塞式的客户端,它在HTTP客户端库(如JDKHttpURLConnection,ApacheHttpComponents,okHttp等)基础封装了更加简单易用的模板方法API。即RestTemplate是一个封装,底层的实现还是java应用开发中常用的一些HTTP客户端。相对于直接使用底层......
  • implement a parallel batch processing in X++ of Dynamics 365 F&O
    OneofthepowerfulfeaturesofDynamics365FinanceandOperationsisaBatchframework.Inthispost,Iexplainhowyoucanconvertyourexistingbatchjobtomulti-threadedtoincreaseitsperformance.InitialexampleLet'sconsiderthefollowing......
  • JdbcTemplate中如何进行存储过程调用
    JdbcTemplate调用存储过程的主要有三种方发(精)一、jdbcTemplate.call()定义如下:Map<String,Object>call(CallableStatementCreatorcsc,List<SqlParameter>declaredParameters)throwsDataAccessException;第一个参数是创建调用存储过程的方法的参数,第二个参数是返回结果的Map......
  • template使用
    template语法template<typenameT>类/函数的实现注意:typename可以指定int,float等内置数据类型,自定义的class模板只有再使用的时候才会定义模板的定义不能与标准库冲突template用法重载的时候//打印不同的数据类型//print(5)//print(5.0f)//print("helloworld!")......
  • JDBC、数据库连接池、Spring JDBC:JdbcTemplate
    JDBCJDBC(JavaDataBaseConnectivity)概念:Java数据库连接,就是通过Java语言操作数据库。JDBC本质:其实是官方(sun公司)定义的一套操作所有关系型数据库的规则,即接口。各个数据库厂商去实现这套接口,提供数据库驱动jar包。我们可以使用这套接口(JDBC)编程,真正执行的代码是驱动jar包中的实......
  • Dynamic Programming
    目录热身198.打家劫舍62.不同路径63.不同路径II213.打家劫舍II337.打家劫舍III参考:https://cloud.tencent.com/developer/article/1692068热身斐波那契数列递归求解自顶向下,存在大量的重复计算动态规划保存中间状态,利用保存的历史状态求解问题,减少了重复计算,空间......
  • template
    templatedemos(......