我试图发布JSON文件到ElasticSearch和面临下面的错误
curl -XPOST http://localhost/test-index/doc -H "Content-Type: application/json" -d @test.json
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [test-index] as the final mapping would have more than 1 type: [_doc, doc]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [test-index] as the final mapping would have more than 1 type: [_doc, doc]"},"status":400}
test.json内容
{
"name":"John Smith",
"age":"38"
}
我错过什么了吗
2条答案
按热度按时间aiazj4mn1#
要使用curl命令将Json数据发布到elasticsearch,您可以尝试以下命令:
您尝试发布Json文件的命令在Postman中运行良好。
i86rm4rw2#
返回的错误为
“reason”:“拒绝对[test-index]的Map更新,因为最终Map将具有多个类型:[_doc]"}]
这意味着您索引已经有一个type doc,您尝试创建一个新的类型doc。作为版本~7.??的弹性支持只有一种类型,你不能创建你的数据。
您需要在请求中的doc前添加“”。
http://localhost/test-index/doc <--不正确
http://localhost/test-index/_doc <--正确