场景复现
请求地址:put http://127.0.0.1:9200/study
,请求内容如下:
{
"mappings": {
"article": {
"properties": {
"id": {
"type": "long",
"store": true,
"index":false
},
"title": {
"type": "text",
"store": true,
"index":true,
"analyzer":"standard"
},
"content": {
"type": "text",
"store": true,
"index":true,
"analyzer":"standard"
}
}
}
}
}
异常信息
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [article : {properties={id={index=false, store=true, type=long}, title={analyzer=standard, index=true, store=true, type=text}, content={analyzer=standard, index=true, store=true, type=text}}}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [article : {properties={id={index=false, store=true, type=long}, title={analyzer=standard, index=true, store=true, type=text}, content={analyzer=standard, index=true, store=true, type=text}}}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [article : {properties={id={index=false, store=true, type=long}, title={analyzer=standard, index=true, store=true, type=text}, content={analyzer=standard, index=true, store=true, type=text}}}]"
}
},
"status": 400
}
失败原因
ElasticSearch7.x
默认不再支持指定索引类型,默认索引类型是_doc
,如果想改变,则配置 include_type_name: true
即可。注意这一字段将在 8.x
舍弃:
请求隐含:
include_type_name=false
官方原文:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
解决办法
- 不指定索引类型,使用默认索引类型
_doc
- 如果你要像之前旧版一样兼容自定义
type
,需要携带参数include_type_name=true
,演示图如下:
网友评论