gpt4 book ai didi

elasticsearch - 如何将没有 ID 的批量插入发送到 elasticsearch

转载 作者:行者123 更新时间:2023-12-02 22:48:20 25 4
gpt4 key购买 nike

我正在尝试使用批量插入 api 进行 Elasticsearch 。我想插入具有自动生成的 ID 的文档,但无论我尝试什么,我都会遇到错误。

以下是一些示例:

http://localhost:9200/_bulk
{"create": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}

put和post都报错:

{
"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 使用 Elasticsearch 6.4.2

~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
elasticsearch 6.4.2 e47ebd7ec3ee 7 weeks ago 828MB

目前正在通过 postman 发送请求

最佳答案

如果您想要自动创建 ID,只需使用 index 而不是 create:

change this
|
v
{"index": {"_index": "test", "_type": "_doc"} }
{"user": "kimchy", "post_date": "2002-11-15T14:12:12", "message": "trying out Elasticsearch"}

关于elasticsearch - 如何将没有 ID 的批量插入发送到 elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53371373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com