1、bulk语法
可操作的类型
- delete 删除一个文档,只要一个json就可以进行操作
- create put /index/_create/id 强制创建
- index 普通的put操作,可以创建文档,也可以时全量替换文档
- update 执行partial update操作
bulk 批量操作,一条错误,不会影响其他条目的更新,在返回时会给出异常
POST /_bulk #一个json为一行,不能换多行{"delete":{"_index":"bobotest","_id":"3"}}{"create":{"_index":"bobotest","_id":"3"}}{"filed":"wuyifanshuaige"}{"index":{"_index":"bobotest","_id":"2"}}{"filed":"test2"}{"update":{"_index":"bobotest","_id":"4"}}{"doc":{"filed":"test4"}}GET /bobotest/_mget{"docs":[{"_index":"bobotest","_id":2},{"_index":"bobotest","_id":3},{"_index":"bobotest","_id":4}]}
2、bulk性能优化
bulk request 会加载到内存中,如果太大,性能反而会有影响,因此要尝试一个最佳的bulk size.一般从1000-5000条数据开始。尝试逐渐增加,看大小,最好在5M-15M之间
