上传多个文档
POST /api/:target/_multi
这将批量创建多个文档。当你有多个要插入的文档时,与 CreateDocument API 相比,它的速度要快得多,因此是首选。
这是一个不同于 bulk
API 的 API,它能在一个请求中接受多行文档。
{ "title": "this is the first document", "attr": "foo" }
{ "title": "this is the second document", "attr": "bar" }
请求示例
POST /api/myindex/_multi
Payload - 多行 json 文本
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"}
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"}
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"}
如果你想使用特殊的文档 ID,你可以在文档中设置 _id
字段。
{"_id": "myid", "Year": 1896, "City": "Athens", "Sport": "Aquatics"}