批量创建文档 V2 版本

POST /api/_bulkv2

这将批量创建多个文档。当你有多个要插入的文档时,与 CreateDocument API 相比,它的速度要快得多,因此是首选。

这是不同的 bulk API,它接受标准的JSON输入。

  1. {
  2. "index": "index name",
  3. "records": [
  4. {
  5. "name": "Prabhat Sharma",
  6. "age": 18
  7. },
  8. {
  9. "name": "Daniel Sharma",
  10. "age": 36
  11. }
  12. ]
  13. }

请求示例

POST /api/_bulkv2

payload - json 内容

  1. {
  2. "index" : "olympics",
  3. "records": [
  4. {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"},
  5. {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"},
  6. {"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"}
  7. ]
  8. }