我有映射
{
"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
参数?
答案 0 :(得分:2)
您要实现的目标称为突破性更改或冲突性更改,这是不可能的,并且错误消息中也提到了相同的内容。
开始思考索引参数的作用及其为何会发生变化索引选项控制是否对字段值建立索引。它接受 true或false,默认为true。未索引的字段是 不可查询。
早期的索引值为false
,因此您现有的文档没有索引的值且不可查询,现在您更改为true
,这没有意义,因为早期的文档将没有索引索引值,这就是所谓的突破性变化的原因。
您必须使用新的索引值创建一个新索引,并且可以使用reindex API。