I have the below format and was hoping to pre-process in bulk using 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"]}
I am trying to add the index,type line before each of my line.
{"index":{"_index":"myindex","_type":"wiki","_id":"1"}}
On reading prior posts I am using Kevin Marsh's post like below:
cat file.json jq -c '.[] | {"index": {"_index": "myindex", "_type": "wiki", "_id": .id}}, .'
I am not using the pipe as I am trying to figure out the error that precedes that.I get an error jq:no such file or directory. I then used jq --version and get jq-1.5-1-a5b5cbe
.
Any help is much appreciated.