(3). 综合:
curl -XPOST 'http://localhost:9200/lib2/books/_bulk?pretty' -H 'Content-Type: application/json' -d '{"delete":{"_index":"lib2","_type":"books","_id":4}}
{"create":{"_index":"tt","_type":"ttt","_id":"100"}}
{"name":"lisi"}
{"index":{"_index":"tt","_type":"ttt"}}
{"name":"zhaosi"}
{"update":{"_index":"lib2","_type":"books","_id":"4"}}
{"doc":{"price":58}}
'
结果:
{
"took" : 307,
"errors" : true, // 表示有错误
"items" : [
...
{
"update" : {
"_index" : "lib2",
"_type" : "books",
"_id" : "4",
"status" : 404,
"error" : {
"type" : "document_missing_exception",
"reason" : "[books][4]: document missing",
"index_uuid" : "QQHMDVPDQ2i2k9CDZMb07g",
"shard" : "0",
"index" : "lib2"
}
}
}
]
}
- bulk一次最大处理多少数据量原理:
a. bulk会把将要处理的数据载入内存中,所以数据量是有限制的.
b. 最佳的数据量不是一个确定的数值,它取决于硬件、文档大小以及复杂性、索引以及搜索的负载.
- 一般建议是1000-5000个文档,大小建议是5-15MB,默认不能超过100M,在es的配置文件(即$ES_HOME下的config下的elasticsearch.yml)中.