除了delete以外,每个操作需要两个json字符串,语法如下:
{"action":{"metadata"}}
{"data"}
bulk api对json字符串的语法有严格的要求,每个json串不能换行,只能放在一行,同时json串和json串之间必须有一个换行

有哪些类型的操作可以执行?
1、delete:删除一个文档
2、create:PUT /index/type/id/_ceate,强制创建
3、index:普通的put操作,可以是创建文档,也可以是全量替换文档
4、update:partial update操作

----------------------------------------------------------------------------------------------------
1、不同index的操作
POST /_bulk
{"delete":{"_index":"test_index1","_type":"test_type","_id":1}}
{"create":{"_index":"test_index2","_type":"test_type","_id":1}}
{"test_field":"test field create"}
{"index":{"_index":"test_index3","_type":"test_type","_id":1}}
{"test_field":"test field index"}
{"update":{"_index":"test_index4","_type":"test_type","_id":1,"_retry_on_conflict":3}}
{"doc":{"test_field":"test field update"}}

bulk操作中,任意一个操作失败不会影响其他的操作,但是在返回的结果集中,会告诉你异常的日志

2、相同index,不同type的操作
{"delete":{"_type":"test_type1","_id":1}}
{"create":{"_type":"test_type2","_id":1}}
{"test_field":"test type ceate"}
{"index":{"_type":"test_type3","_id":1}}
{"test_field":"test type index"}
{"update":{"_type":"test_type4","_id":1,"_retry_on_conflict":3}}
{"doc":{"test_field":"test type update"}}

3、相同index、type,不同id的操作
{"delete":{"_id":1}}
{"ceate":{"_id":2}}
{"test_field":"test id create"}
{"index":{"_id":3}}
{"test_field":"test id index"}
{"update":{"_id":4,"_retry_on_conflict":3}}
{"doc":{"test_field":"test id update"}}

4、bulk size最佳大小
bulk request内容会加载到内存中,如果太大的话,性能反而会降低,因此需要反复尝试,得到一个最佳的bulk size
一般从1000条数据开始,逐渐成倍的增加。
如果看数据文件大小的话,最好是在5到15M之间。

最新文章

  1. Core Text概述
  2. SharePoint 项目的死法(一)
  3. Contest1065 - 第四届“图灵杯”NEUQ-ACM程序设计竞赛(个人赛)D拿糖果
  4. python basic programs
  5. EasyUI DataGrid 添加 Footer
  6. VMware下安装CentOS6.5
  7. tp中like多字段同时怎么模糊搜索
  8. Redux入门示例-TodoList
  9. PHP+MySQL分页显示示例分析
  10. 【Matlab编程】Matlab高效编程技巧
  11. cesium 之加载地形图 Terrain 篇(附源码下载)
  12. [转] 从零构建 vue2 + vue-router + vuex 开发环境到入门,实现基本的登录退出功能
  13. PHP----------php封装的一些简单实用的方法汇总
  14. 如何创建 SVN 服务器,并搭建自己的 SVN 仓库 如何将代码工程添加到VisualSVN Server里面管理
  15. 目标检测(四)Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
  16. slurm.conf系统初始配置
  17. node.js 在使用child_process 模块时候,调试端口占用的问题解决方案(EADDRINUSE)
  18. P1649 [USACO07OCT]障碍路线Obstacle Course
  19. odoo开发思路篇
  20. 在Jmeter中用JAVA获取Rolling Date

热门文章

  1. VS2012+openCV 2.4.8进行编译:VS2012 64位 使用OPENCV应用程序不能正常启动 (0xc000007b)怎么处理?
  2. python一天一题(3)
  3. LeetCode_1. Two Sum_Solution
  4. Java如何检查文件是否在服务器上被修改了?
  5. MyCAT简易入门 (Linux)
  6. IDEA 最新版破解教程图解
  7. spring quartz1.8.6集群结算服务定时任务与appserver独立分开
  8. jar各个版本号的意义
  9. go语言内置基础类型
  10. 从Elasticsearch来看分布式系统架构设计