when Elasticsearch creates mapping, it will report an error if the same field name of different type is set to different type, so how to solve this situation?
request a connection
PUT http://localhost:9200/new
parameters are as follows:
{
"max_result_window": "1000000",
"_source" : {
"enabled": true
},
"_all" : {
"enabled": false
},
"mappings": {
"type1": {
"properties": {
"@timestamp" : {
"type" : "date"
},
"@version" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"create_time" : {
"index": "not_analyzed",
"type" : "long"
}
}
},
"type2": {
"properties": {
"@timestamp" : {
"type" : "date"
},
"@version" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"create_time" : {
"index": "not_analyzed",
"type" : "date"
}
}
}
}
}
request result:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "mapper [create_time] cannot be changed from type [date] to [long]"
}
],
"type": "illegal_argument_exception",
"reason": "mapper [create_time] cannot be changed from type [date] to [long]"
},
"status": 400
}