一、批量添加
POST /lib2/books/_bulk
{"index":{"_id":1}}
{"title":"java","price":55}
{"index":{"_id":2}}
{"title":"html","price":45}
{"index":{"_id":3}}
{"title":"php","price":50}
{"index":{"_id":4}}
{"title":"python","price":65}
二、批量获取
GET /lib2/books/_mget
{
"ids":["1","2","3","4"]
}
三、
POST /lib2/books/_bulk
{"delete":{"_index":"lib2","_type":"books","_id":4}}
{"create":{"_index":"tt","_type":"ttt","_id":100}}
{"name":"lisi"}
{"index":{"_index":"tt","_type":"ttt"}}
{"name":"zhaosi"}
{"updata":{"_index":"lib2","_type":"books","_id":4}}
{"doc":{"price":58}}
四、bulk最大处理数据量
bulk会把处理的数据放到内存中,所以数据量是哟限制的,最佳的数据量不是一个定值,你的文档大小以及复杂性,你的索引以及搜索的负载
一般建议是1000-5000个文档,大小建议是5-15M,默认不能超过100M,可以在es的配置文件(elasticsearch。yml)中配置