【发布时间】:2018-03-29 10:16:16
【问题描述】:
我有以下格式,并希望使用 elasticsearch 进行批量预处理。
{"title":"April","url":"https://simple.wikipedia.org/wiki/April", "abstract":"April is the 4th month of the year, and comes between March and May. It is one of four months to have 30 days.","sections":["The Month","April in poetry","Events in April","Fixed Events","Moveable Events","Selection of Historical Events","Trivia","References"]}
{"title":"August","url":"https://simple.wikipedia.org/wiki/August", "abstract":"August (Aug.) is the 8th month of the year in the Gregorian calendar, coming between July and September.","sections":["The Month","August observances","Fixed observances and events","Moveable and Monthlong events","Selection of Historical Events","Trivia","References"]}
我正在尝试在我的每一行之前添加索引、类型行。
{"index":{"_index":"myindex","_type":"wiki","_id":"1"}}
在阅读之前的帖子时,我使用的是Kevin Marsh's post,如下所示:
cat file.json jq -c '.[] | {"index": {"_index": "myindex", "_type": "wiki", "_id": .id}}, .'
我没有使用管道,因为我试图找出之前的错误。我收到错误 jq:no such file or directory。然后我使用了jq --version and get jq-1.5-1-a5b5cbe。
非常感谢任何帮助。
【问题讨论】:
-
不确定您需要什么。
-
感谢 Hatim,希望能找到我的 cat 语句中是否存在问题,或者找到更好的解决方案来更改格式,以便使用弹性搜索为批量 api 做好准备。
-
据我了解,您有一个 json 文件,您想使用 Bulk API 在 Elasticsearch 中对其进行索引。对吗?
-
是的 Hatim 及其超过 10000 行,如上,我想通过 addin {"index":{"_index":"myindex","_type":"wiki", "_id":"1"}} 在 json 文件中的每个对象之前。
-
您需要正确格式化您的问题,它非常无组织
标签: json elasticsearch jq elasticsearch-bulk-api