新建索引时,报错Root mapping definition has unsupported parameters
PUT /cars
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"transactions": {
"properties": {
"color": {
"type": "keyword"
},
"make": {
"type": "keyword"
}
}
}
}
}
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [transactions : {properties={color={type=keyword}, make={type=keyword}}}]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [transactions : {properties={color={type=keyword}, make={type=keyword}}}]",
"caused_by" : {
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [transactions : {properties={color={type=keyword}, make={type=keyword}}}]"
}
},
"status" : 400
}
查看官网示例后发现 7.10.1 默认不再支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false)。参见官网
解决方法:添加?include_type_name=true
后,索引添加成功
PUT /cars?include_type_name=true
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"transactions": {
"properties": {
"color": {
"type": "keyword"
},
"make": {
"type": "keyword"
}
}
}
}
}
#! Deprecation: [types removal] Using include_type_name in create index requests is deprecated. The parameter will be removed in the next major version.
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "cars"
}
提示include_type_name
会在下一个主要版本被移除
最新回复