对于稳定的集群,settings 主要用于设置索引的分片及副本数。而索引设置分为 static 和 dynamic 修改,动态修改通常使用 settings API 进行修改。
获取索引的配置信息,以下信息可以看出,索引为一主分片一副本分片
GET test/_settings
{
"test" : {
"settings" : {
"index" : {
"refresh_interval" : "30s",
"number_of_shards" : "1",
"translog" : {
"sync_interval" : "5s",
"durability" : "async"
},
"provided_name" : "test",
"max_result_window" : "65536",
"creation_date" : "1592816713467",
"unassigned" : {
"node_left" : {
"delayed_timeout" : "5m"
}
},
"number_of_replicas" : "1",
"uuid" : "WowQ62uqTJW2gFLo1SAh-A",
"version" : {
"created" : "7050199"
}
}
}
}
}
settings 不可修改主分片数量,仅能动态修改索引副本分片数量
PUT test/_settings
{
"number_of_replicas":2
}
若将 ES 当做数据库来理解,mappings 可视为其中的表结构。但 mappings 比表结构更加灵活,不指定也可以根据数据类型动态识别,若需要添加特殊属性则要手动指定 mappings.
PUT people
{
"mappings": {
"properties": {
"name": {"type": "text"},
"age": {"type": "integer"},
"sex": {"type": "text"},
"rank": {"type": "text"}
}
}
}
PUT people/_mapping
{
"properties": {
"employee-id": {
"type": "keyword",
"index": false
}
}
}
version | pattern |
---|---|
5.6.x | 可手动启用“index.mapping.single_type: true”,使用 join 字段进行替换 |
6.x | 允许索引使用单一类型,有且仅有一个名称,首选_doc 类型; 5.x 版本的索引可延续使用,新版本的索引不再支持父/子方式和 join 类型; 6.8中需要在索引创建、模板时需要显示指定 include _ type _ name,不显示申明会默认为 name _ doc |
7.x | _doc 是路径中的永久部分,并且表示的是 endpoint 类型,而不是 doc 类型; include _ type _ name 参数默认为 false 移除 _default_ mapping 类型 |
8.x | 不再支持特殊类型 移除 include_type_name 参数 |
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有