我创建了带有显式映射的索引:
PUT http://192.168.1.71:9200/items
{
"mappings": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"num": {
"type": "long"
}
}
}
}
并尝试添加文档:
POST http://192.168.1.71:9200/items/1
{
"num" : 1.898,
"name" : "aaa"
}
但是得到错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [items] as the final mapping would have more than 1 type: [_doc, 1]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [items] as the final mapping would have more than 1 type: [_doc, 1]"
},
"status": 400
}
为什么以及如何适应它?
答案 0 :(得分:1)
您需要在id
之前的_doc
之前指定文档类型
POST http://192.168.1.71:9200/items/_doc/1
{
"num" : 1.898,
"name" : "aaa"
}