elasticsearch - 更新 Elasticsearch 中现有字段的映射索引参数
问题描述
我有映射
{
"test" : {
"mappings" : {
"properties" : {
"description" : {
"type" : "text"
},
"location" : {
"type" : "keyword",
"index" : false
},
"title" : {
"type" : "text"
}
}
}
}
}
我想将该字段的index
参数更新为location
true
我在尝试
PUT /test/_mapping
{
"properties": {
"location": {
"type": "keyword",
"index": true
}
}
}
我得到
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values]"}],"type":"illegal_argument_exception","reason":"Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values]"},"status":400}
如何更新index
参数?
解决方案
您要实现的目标称为破坏性更改或冲突性更改,这是不可能的,错误消息中也提到了这一点。
从索引文档中思考索引参数的作用以及为什么它会发生重大变化
index 选项控制字段值是否被索引。它接受真或假,默认为真。未编入索引的字段不可查询。
早期的索引值是false
因为您现有的文档没有索引值并且不可查询,现在您更改为true
哪个没有意义,因为您的早期文档将没有索引值,这就是它称为重大更改的原因。
您必须使用新的索引值创建一个新索引,并且可以为此使用reindex API。
推荐阅读
- excel - 根据我们可能所在的前一个月过滤12个月前的数据,而无需手动输入开始和结束日期?
- c# - 为什么我的服务器无法响应来自网络浏览器的客户端请求?
- r - 如何在ggplot2的文本中下标字母或数字
- java - 如何使用 selenium 检查警报的可见性
- reactjs - 无法在反应js中获取道具中的数据
- web-services - 如何从外部监听客户端对 ASMX Web 服务服务器的调用?
- mongodb - 带有添加字段的 Mongolite 聚合查询
- php - 在 laravel 中使用 import excel 更新 join 2 表
- sql-server - 使用日期时间参数从 Excel PowerQuery 调用 SQL Server 存储过程对我不起作用
- kettle - 在转换中解析 CSV