1:bulk 是 elasticsearch 提供的一种批量增删改的操作API
bulk 对 JSON串 有着严格的要求。每个JSON串 不能换行 ,只能放在同一行,同时, 相邻的JSON串之间必须要有换行 (Linux下是\n;Window下是\r\n)。bulk的每个操作必须要 一对JSON串 (delete语法除外)。
bulk 请求体如下:
{ action: { metadata }}\n
{ request body }\n
{ action: { metadata }}\n
{ request body }\n
2:action必须是以下几种:
测试索引示例
PUT batch_test
{
“mappings”: {
“properties”: {
“id”:{
“type”: “keyword”
},
“name”:{
“type”: “text”
},
“age”:{
“type”: “integer”
}
}
}
}
测试原始数据
PUT /_bulk
{“index”:{“_index”:“batch_test”,“_id”:“101”}}
{“doc”:{“name”:“测试create数据101”,“age”:“21”}}
{“index”:{“_index”