我正在尝试使用批量插入api进行弹性搜索。我想插入具有自动生成的ID的文档,但是无论尝试如何,我都会遇到错误。
以下是一些示例工作:
http://localhost:9200/_bulk
{"create": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}
放置和发布都给出错误:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: an id must be provided if version type or value are set;"
},
"status": 400
}
如果我删除_type _doc,则会出现以下错误:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: type is missing;2: an id is required for a CREATE operation;3: an id must be provided if version type or value are set;"
},
"status": 400
}
我正在通过docker使用弹性搜索6.4.2
~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB
当前通过邮递员发送请求
答案 0 :(得分:1)
如果要自动创建ID,只需使用index
而不是create
:
change this
|
v
{"index": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}