新建索引
PUT /test2
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 0
},
"mappings": {
"user":{
"properties":{
"id":{
"type":"long"
},
"title":{
"type":"text",
"analyzer":"ik_max_word"
},
"content":{
"type":"text",
"analyzer":"ik_max_word"
},
"postdate":{
"type":"date"
},
"url":{
"type":"text"
}
}
}
}
}
然后报错,Root mapping definition has unsupported parameters
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [user : {properties={postdate={type=date}, id={type=long}, title={analyzer=ik_max_word, type=text}, content={analyzer=ik_max_word, type=text}, url={type=text}}}]"
}
},
"status": 400
}
查看官网示例后发现 7.4 默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false)。见官网:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_typeless_apis_in_7_0
修改成:
PUT /test2
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 0
},
"mappings": {
"properties":{
"id":{
"type":"long"
},
"title":{
"type":"text",
"analyzer":"ik_max_word"
},
"content":{
"type":"text",
"analyzer":"ik_max_word"
},
"postdate":{
"type":"date"
},
"url":{
"type":"text"
}
}
}
}
成功
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test2"
}