gpt4 book ai didi

elasticsearch - Elasticsearch Bulk API:不能发布多个记录

转载 作者:行者123 更新时间:2023-12-02 22:46:41 28 4
gpt4 key购买 nike

我正在尝试使用批量API发布以下内容。我有ES 2.2.0

{"index":{"_index":"junktest","_type":"test"}}
{"DocumentID":"555662","Tags":["B","C","D"],"Summary":"Summary Text","Status":"Review","Location":"HDFS","Error":"None","Author":"Abc Mnb","Sector":"Energy","Created Date":"2013-05-23"},
{"DocumentID":"555663","Tags":["A","B","C"],"Summary":"Summary Text","Status":"Review","Location":"HDFS","Error":"None","Author":"Abc Mnb","Sector":"Energy","Created Date":"2013-04-25"}


curl -XPOST "http://localhost:9200/_bulk" --data-binary @post.json

但是我明白了
  {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed
action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_
STRING]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"},"status":400}

为什么 },无效?我什至没有逗号尝试过,但即使我没有 ,,我仍然会收到错误消息!

我的语法有什么问题?

编辑

我能够通过它来工作
{"index":{"_index":"junktest","_type":"test"}}
{"DocumentID":"555662","Tags":["B","C","D"],"Summary":"Summary Text","Status":"Review","Location":"HDFS","Error":"None","Author":"Abc Mnb","Sector":"Energy","Created Date":"2013-05-23"}
{"index":{"_index":"junktest","_type":"test"}}
{"DocumentID":"555663","Tags":["A","B","C"],"Summary":"Summary Text","Status":"Review","Location":"HDFS","Error":"None","Author":"Abc Mnb","Sector":"Energy","Created Date":"2013-04-25"}

这是使用批量api索引多个记录的唯一方法吗?

最佳答案

从文档中

The REST API endpoint is /_bulk, and it expects the following JSON structure:

action_and_meta_data\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n

document source是可选的,但是 action_meta_data是必需的,并且两者之间用新行分隔。
鉴于这些限制,您只能为每个操作指定一条记录。

同样在您提供的示例中,您没有在元数据中传递“_id”,这意味着“_id”是自动生成的。可能是故意的,但请记住,如果您打算更新文档,则将无法使用 DocumentId

关于elasticsearch - Elasticsearch Bulk API:不能发布多个记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35184964/

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