elasticsearch版本6.8.4,我有一個索引megacorp,類型employee,查看索引映射如下
GET /megacrop/_mapping
{
"megacrop": {
"mappings": {
"megacrop": {
"properties": {
"about": {
"type": "keyword"
},
"age": {
"type": "integer"
},
"firstName": {
"type": "keyword"
},
"id": {
"type": "keyword"
},
"interests": {
"type": "keyword"
},
"lastName": {
"type": "keyword"
}
}
}
}
}
}
現在我想把其中的interests列改爲支持聚合查詢,需要增加"fielddata": true屬性
執行命令 PUT /megacorp/_mapping
{
"employee": {
"properties": {
"about": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"age": {
"type": "long"
},
"first_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"interests": {
"type": "text",
"fielddata": true,
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"last_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
報錯
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
},
"status": 400
}
檢查發現是地址寫錯了,應該是PUT /megacorp/employee/_mapping
修改後執行成功