拒绝将映射更新更新为[],因为最终映射将具有1种以上的类型

时间:2019-09-16 16:59:11

标签: elasticsearch

我创建了带有显式映射的索引:

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
}

为什么以及如何适应它?

1 个答案:

答案 0 :(得分:1)

您需要在id之前的_doc之前指定文档类型

POST http://192.168.1.71:9200/items/_doc/1
{
  "num" : 1.898,
  "name" : "aaa"   
}