elasticsearch - Elasticsearch 为多个索引中的所有字段设置 `ignore_above`
问题描述
200+
我有一个带索引的弹性搜索。文档有时包含无用的长文本字段,并且会占用过多的索引能力。
我想ignore_above
自动为所有索引中的所有字段设置限制。我正在尝试为此使用索引模板。
我找到了如何按名称为特定字段设置它的示例。
如何将它应用于所有(当前和未来)索引和字段?
解决方案
如何将它应用于所有(当前和未来)索引和字段?
模板中的设置仅适用于新索引。对于现有索引,您需要更新mappings
各个索引的 。
在所有索引中应用此设置的方式因不同的 Elasticsearch 版本而异。我可以向您展示我尝试过的两个版本,并且知道它有效。
ES 2.4
"mappings": {
"_default_": {
"dynamic_templates": [
{
"string_fields": {
"mapping": {
"ignore_above": 10922,
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "*"
}
}
]
},
"<your object type>": {
<other settings>
}
}
ES 6.1
"mappings": {
"_default_" : {
"dynamic_templates" : [
{
"string_fields" : {
"mapping" : {
"type" : "keyword",
"ignore_above" : 8191,
"index": true
},
"match_mapping_type" : "string",
"match" : "*"
}
}
]
},
"<your object type>": {
<other settings>
}
}
mappings
under_default_
将适用于所有对象类型,并且可以使用设置 under 覆盖<your object type>
。
高温高压
推荐阅读
- sql - 不使用内部联接的 Sql 查询
- artisan-migrate - Migration Command issue
- python - 如何识别有关考试成绩的列数据中的异常值并返回异常值的国家/地区名称
- c# - 是否可以在 .net mvc 和 c# 的静态道具中维护聊天消息?
- docker - Re using existing volume at docker-compose ELK stack
- asp.net-identity - ASP.Net Core Identity - 加入多个Authroize-Attr
- docker - 当运行错误代码 139 时,docker 立即退出
- c# - C# LINQ 左连接 2 个数据表
- php - 登录laravel5.7后跳转到上一页
- regex - 如何通过记事本++中的正则表达式删除所有行包括'collect_host_stats'