ElasticSearch 7.x default does not support the specified index type
Executed on elasticsearch7.x:
-
put es_test
-
{
-
"settings":{
-
"number_of_shards" :
3,
-
"number_of_replicas" :
0
-
},
-
"mappings":{
-
"books":{
-
"properties":{
-
"title":{
"type":
"text"},
-
"name":{
"type":
"text",
"index":
false},
-
"publish_date":{
"type":
"date",
"index":
false},
-
"price":{
"type":
"double"},
-
"number":{
-
"type":
"object",
-
"dynamic":
true
-
}
-
}
-
}
-
}
-
}
The results will be wrong: Root mapping definition has unsupported parameters
-
{
-
"error": {
-
"root_cause": [
-
{
-
"type":
"mapper_parsing_exception",
-
"reason":
"Root mapping definition has unsupported parameters: [books : {properties={number={dynamic=true, type=object}, price={type=double}, name={index=false, type=text}, title={type=text}, publish_date={index=false, type=date}}}]"
-
}
-
],
-
"type":
"mapper_parsing_exception",
-
"reason":
"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [books : {properties={number={dynamic=true, type=object}, price={type=double}, name={index=false, type=text}, title={type=text}, publish_date={index=false, type=date}}}]",
-
"caused_by": {
-
"type":
"mapper_parsing_exception",
-
"reason":
"Root mapping definition has unsupported parameters: [books : {properties={number={dynamic=true, type=object}, price={type=double}, name={index=false, type=text}, title={type=text}, publish_date={index=false, type=date}}}]"
-
}
-
},
-
"status":
400
-
}
If executed on 6.x, are executed normally
-
{
-
"acknowledged" :
true
-
}
This occurs because, elasticsearch7 default does not support the specified index type, default index type is _doc, if you want to change, include_type_name configure: true to (this is not a test, the official said the document, whether it is feasible, it is recommended not to do so because after elasticsearch8 not provide this field). The official document: https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
So Elasticsearch7 should create an index so
-
put /
test
-
{
-
"settings":{
-
"number_of_shards":3,
-
"number_of_replicas":2
-
},
-
"mappings":{
-
"properties":{
-
"id":{
"type":
"long"},
-
"name":{
"type":
"text",
"analyzer":
"ik_smart"},
-
"text":{
"type":
"text",
"analyzer":
"ik_max_word"}
-
}
-
}
-
-
}
-
-
-
put /test1
-
{
-
"settings":{
-
"number_of_shards":3,
-
"number_of_replicas":2
-
},
-
"mappings":{
-
"properties":{
-
"id":{
"type":
"long"},
-
"name":{
"type":
"text"},
-
"text":{
"type":
"text"}
-
}
-
}
-
-
}
For students interested in artificial intelligence, you can click on the following link: