尝试创建自定义映射类型时会发生此问题。
为第一个插入弹性创建自定义映射后想要创建_doc
映射类型和冲突就发生在这里。
第一步我创建一个映射
{
"mappings": {
"properties": {
"field1": {
"type": "keyword"
},
"field2": {
"type": "short",
"index": false
}
}
}
}
进入第二步,将第一个数据放入弹性中
curl --location --request PUT 'localhost:9200/myindex/mydoc/1
{
"field1": "first info",
"field2": 0
}
但在第二步中,当我尝试将第一个数据放入弹性时遇到以下错误
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [field2] conflicts with existing mapper:\n\tCannot update parameter [index] from [false] to [true]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [field2] conflicts with existing mapper:\n\tCannot update parameter [index] from [false] to [true]"
},
"status": 400
似乎在这一步中弹性尝试创建动态映射,并且该映射想要创建 field2 作为索引字段。
还根据我使用的另一个答案dynamic: false
or dynamic: "strict"
在映射中设置像跟随块代码,但它不起作用
{
"mappings": {
"dynamic": false,
"properties": {
"field1": {
"type": "keyword"
},
"field2": {
"type": "short",
"index": false
}
}
}
}
字段类型也会发生此错误。例如,我的字段类型是“关键字”,但在自动映射上尝试将此类型转换为“文本”!