ElasticSearch V7.10.2: Root mapping definition has unsupported parameters分析

哈哈 阅读:320 2021-03-31 12:45:19 评论:0

问题描述:

基于elasticsearch7 插件开发规则,编写初始化索引插件(elasticsearch-plug-index),初始化索引mapping 映射

{ 
	"settings": { 
		"number_of_shards": 3, 
		"number_of_replicas": 2 
	}, 
	"mappings": { 
		"properties": { 
			"approvallanduseno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"archcategorycode": { 
				"type": "text", 
				"store": true 
			}, 
			"archid": { 
				"type": "text", 
				"store": true 
			}, 
			"archivingdate": { 
				"type": "date" 
			}, 
			"archivingdateyear": { 
				"type": "text", 
				"fielddata": true 
			}, 
			"archtitle": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword" 
					} 
				}, 
				"analyzer": "ik_max_word" 
			}, 
			"archtype": { 
				"type": "text" 
			}, 
			"archtypecode": { 
				"type": "text", 
				"analyzer": "ik_max_word" 
			}, 
			"archtypename": { 
				"type": "text" 
			}, 
			"assortnum": { 
				"type": "text", 
				"store": true, 
				"analyzer": "ik_max_word" 
			}, 
			"assortnumname": { 
				"type": "keyword" 
			}, 
			"conspermitno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"consplanningno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"enddate": { 
				"type": "date" 
			}, 
			"engprojsid": { 
				"type": "text", 
				"store": true 
			}, 
			"individualprojsid": { 
				"type": "text", 
				"store": true 
			}, 
			"landuseno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"landuseplanningno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"makeorgname": { 
				"type": "text", 
				"analyzer": "ik_max_word" 
			}, 
			"oldunitprojid": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"organizationcode": { 
				"type": "text", 
				"store": true, 
				"analyzer": "ik_max_word" 
			}, 
			"organizationcodename": { 
				"type": "keyword" 
			}, 
			"planningverifycertificateno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"projacceprecordno": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"regno": { 
				"type": "text", 
				"analyzer": "ik_max_word" 
			}, 
			"securitylevelcode": { 
				"type": "text" 
			}, 
			"sid": { 
				"type": "text", 
				"store": true 
			}, 
			"speccode": { 
				"type": "text", 
				"analyzer": "ik_max_word" 
			}, 
			"startdate": { 
				"type": "date" 
			}, 
			"storagetypecode": { 
				"type": "text" 
			}, 
			"unitprojarchno": { 
				"type": "text", 
				"analyzer": "ik_max_word" 
			}, 
			"unitprojid": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"unitprojname": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"unitprojsid": { 
				"type": "text", 
				"store": true 
			}, 
			"unitprojtype": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"unitprojtypename": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"unitprojzone": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			}, 
			"unitprojzonename": { 
				"type": "text", 
				"fields": { 
					"keyword": { 
						"type": "keyword", 
						"ignore_above": 256 
					} 
				} 
			} 
 
		} 
	} 
}

异常信息:

{ 
    "error": { 
        "root_cause": [ 
            { 
                "type": "mapper_parsing_exception", 
                "reason": "Root mapping definition has unsupported parameters:  [unitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [storagetypecode : {type=text}] [planningverifycertificateno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archid : {store=true, type=text}] [archtitle : {analyzer=ik_max_word, type=text, fields={keyword={type=keyword}}}] [startdate : {type=date}] [unitprojarchno : {analyzer=ik_max_word, type=text}] [unitprojtype : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtypename : {type=text}] [archivingdate : {type=date}] [projacceprecordno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [sid : {store=true, type=text}] [assortnumname : {type=keyword}] [organizationcodename : {type=keyword}] [landuseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojzone : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [consplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archivingdateyear : {fielddata=true, type=text}] [assortnum : {analyzer=ik_max_word, store=true, type=text}] [securitylevelcode : {type=text}] [regno : {analyzer=ik_max_word, type=text}] [makeorgname : {analyzer=ik_max_word, type=text}] [organizationcode : {analyzer=ik_max_word, store=true, type=text}] [unitprojtypename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtype : {type=text}] [landuseplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archcategorycode : {store=true, type=text}] [archtypecode : {analyzer=ik_max_word, type=text}] [enddate : {type=date}] [unitprojsid : {store=true, type=text}] [individualprojsid : {store=true, type=text}] [oldunitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [speccode : {analyzer=ik_max_word, type=text}] [approvallanduseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [conspermitno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojname : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [engprojsid : {store=true, type=text}] [unitprojzonename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}]" 
            } 
        ], 
        "type": "mapper_parsing_exception", 
        "reason": "Failed to parse mapping [properties]: Root mapping definition has unsupported parameters:  [unitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [storagetypecode : {type=text}] [planningverifycertificateno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archid : {store=true, type=text}] [archtitle : {analyzer=ik_max_word, type=text, fields={keyword={type=keyword}}}] [startdate : {type=date}] [unitprojarchno : {analyzer=ik_max_word, type=text}] [unitprojtype : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtypename : {type=text}] [archivingdate : {type=date}] [projacceprecordno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [sid : {store=true, type=text}] [assortnumname : {type=keyword}] [organizationcodename : {type=keyword}] [landuseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojzone : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [consplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archivingdateyear : {fielddata=true, type=text}] [assortnum : {analyzer=ik_max_word, store=true, type=text}] [securitylevelcode : {type=text}] [regno : {analyzer=ik_max_word, type=text}] [makeorgname : {analyzer=ik_max_word, type=text}] [organizationcode : {analyzer=ik_max_word, store=true, type=text}] [unitprojtypename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtype : {type=text}] [landuseplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archcategorycode : {store=true, type=text}] [archtypecode : {analyzer=ik_max_word, type=text}] [enddate : {type=date}] [unitprojsid : {store=true, type=text}] [individualprojsid : {store=true, type=text}] [oldunitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [speccode : {analyzer=ik_max_word, type=text}] [approvallanduseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [conspermitno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojname : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [engprojsid : {store=true, type=text}] [unitprojzonename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}]", 
        "caused_by": { 
            "type": "mapper_parsing_exception", 
            "reason": "Root mapping definition has unsupported parameters:  [unitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [storagetypecode : {type=text}] [planningverifycertificateno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archid : {store=true, type=text}] [archtitle : {analyzer=ik_max_word, type=text, fields={keyword={type=keyword}}}] [startdate : {type=date}] [unitprojarchno : {analyzer=ik_max_word, type=text}] [unitprojtype : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtypename : {type=text}] [archivingdate : {type=date}] [projacceprecordno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [sid : {store=true, type=text}] [assortnumname : {type=keyword}] [organizationcodename : {type=keyword}] [landuseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojzone : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [consplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archivingdateyear : {fielddata=true, type=text}] [assortnum : {analyzer=ik_max_word, store=true, type=text}] [securitylevelcode : {type=text}] [regno : {analyzer=ik_max_word, type=text}] [makeorgname : {analyzer=ik_max_word, type=text}] [organizationcode : {analyzer=ik_max_word, store=true, type=text}] [unitprojtypename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archtype : {type=text}] [landuseplanningno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [archcategorycode : {store=true, type=text}] [archtypecode : {analyzer=ik_max_word, type=text}] [enddate : {type=date}] [unitprojsid : {store=true, type=text}] [individualprojsid : {store=true, type=text}] [oldunitprojid : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [speccode : {analyzer=ik_max_word, type=text}] [approvallanduseno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [conspermitno : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [unitprojname : {type=text, fields={keyword={ignore_above=256, type=keyword}}}] [engprojsid : {store=true, type=text}] [unitprojzonename : {type=text, fields={keyword={ignore_above=256, type=keyword}}}]" 
        } 
    }, 
    "status": 400 
}

失败原因

ElasticSearch7.x 默认不再支持指定索引类型,默认索引类型是_doc,如果想改变,则配置 include_type_name: true 即可。注意这一字段将在 8.x 舍弃

官方原文:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

 

解决办法

方式一:不指定索引类型,使用默认索引类型_doc

{ 
	"settings": { 
		"number_of_shards": 1, 
		"number_of_replicas": 1 
	}, 
	"mappings": { 
		"_doc": { 
			"properties": { 
				"approvallanduseno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"archcategorycode": { 
					"type": "text", 
					"store": true 
				}, 
				"archid": { 
					"type": "text", 
					"store": true 
				}, 
				"archivingdate": { 
					"type": "date" 
				}, 
				"archivingdateyear": { 
					"type": "text", 
					"fielddata": true 
				}, 
				"archtitle": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword" 
						} 
					}, 
					"analyzer": "ik_max_word" 
				}, 
				"archtype": { 
					"type": "text" 
				}, 
				"archtypecode": { 
					"type": "text", 
					"analyzer": "ik_max_word" 
				}, 
				"archtypename": { 
					"type": "text" 
				}, 
				"assortnum": { 
					"type": "text", 
					"store": true, 
					"analyzer": "ik_max_word" 
				}, 
				"assortnumname": { 
					"type": "keyword" 
				}, 
				"conspermitno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"consplanningno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"enddate": { 
					"type": "date" 
				}, 
				"engprojsid": { 
					"type": "text", 
					"store": true 
				}, 
				"individualprojsid": { 
					"type": "text", 
					"store": true 
				}, 
				"landuseno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"landuseplanningno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"makeorgname": { 
					"type": "text", 
					"analyzer": "ik_max_word" 
				}, 
				"oldunitprojid": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"organizationcode": { 
					"type": "text", 
					"store": true, 
					"analyzer": "ik_max_word" 
				}, 
				"organizationcodename": { 
					"type": "keyword" 
				}, 
				"planningverifycertificateno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"projacceprecordno": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"regno": { 
					"type": "text", 
					"analyzer": "ik_max_word" 
				}, 
				"securitylevelcode": { 
					"type": "text" 
				}, 
				"sid": { 
					"type": "text", 
					"store": true 
				}, 
				"speccode": { 
					"type": "text", 
					"analyzer": "ik_max_word" 
				}, 
				"startdate": { 
					"type": "date" 
				}, 
				"storagetypecode": { 
					"type": "text" 
				}, 
				"unitprojarchno": { 
					"type": "text", 
					"analyzer": "ik_max_word" 
				}, 
				"unitprojid": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"unitprojname": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"unitprojsid": { 
					"type": "text", 
					"store": true 
				}, 
				"unitprojtype": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"unitprojtypename": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"unitprojzone": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				}, 
				"unitprojzonename": { 
					"type": "text", 
					"fields": { 
						"keyword": { 
							"type": "keyword", 
							"ignore_above": 256 
						} 
					} 
				} 
			} 
		} 
	} 
}

方式二:如果你要像之前旧版一样兼容自定义 type ,需要携带参数 include_type_name=true,由于我使用是自定义插件导入索引,所以没有采用这种方式。

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
KIKK导航

KIKK导航

排行榜
关注我们

一个IT知识分享的公众号