批量创建文档 V2 版本
POST /api/_bulkv2
这将批量创建多个文档。当你有多个要插入的文档时,与 CreateDocument API 相比,它的速度要快得多,因此是首选。
这是不同的 bulk
API,它接受标准的JSON输入。
{
"index": "index name",
"records": [
{
"name": "Prabhat Sharma",
"age": 18
},
{
"name": "Daniel Sharma",
"age": 36
}
]
}
请求示例
POST /api/_bulkv2
payload - json 内容
{
"index" : "olympics",
"records": [
{"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"}
]
}