我有以下格式,希望能夠使用elasticsearch預批量預處理。如何批量更改彈性搜索的JSON格式
{"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}}, .'
我不使用,因爲我想弄清楚,先that.I得到一個錯誤JQ錯誤的管道:無此文件或目錄。然後我用jq --version and get jq-1.5-1-a5b5cbe
。
任何幫助,非常感謝。
不確定你需要什麼。 –
感謝Hatim,希望能夠發現我的貓語句中是否存在問題,或者更好的解決方案,以便使用彈性搜索將格式更改爲準備使用批量api。 – ESLearner
根據我的理解,您有一個json文件,並且您想使用批量API在Elasticsearch中對其進行索引。對? –