大家,也可去看看我下面的博客
Elasticsearch之批量操作bulk
官网上,是举例了新建一个requests文件。
[hadoop@master elasticsearch-2.4.]$ pwd
/home/hadoop/app/elasticsearch-2.4.
[hadoop@master elasticsearch-2.4.]$ ll
total
drwxrwxr-x hadoop hadoop Apr : bin
drwxrwxr-x hadoop hadoop Jun : config
drwxrwxr-x hadoop hadoop Apr : lib
-rw-rw-r-- hadoop hadoop Aug LICENSE.txt
drwxrwxr-x hadoop hadoop Aug modules
-rw-rw-r-- hadoop hadoop Aug NOTICE.txt
drwxrwxr-x hadoop hadoop Apr : plugins
-rw-rw-r-- hadoop hadoop Aug README.textile
[hadoop@master elasticsearch-2.4.]$ vim requests
{ "index" : { "_index" : "zhouls", "_type" : "user", "_id" : "" } }
{ "name" : "mayun" , "age" : "" }
{ "update" : { "_index" : "zhouls", "_type" : "user", "_id" : "" } }
{ "doc" : { "age" : }}
然后,执行批量操作
[hadoop@master elasticsearch-2.4.]$ pwd
/home/hadoop/app/elasticsearch-2.4.
[hadoop@master elasticsearch-2.4.]$ ll
total
drwxrwxr-x hadoop hadoop Apr : bin
drwxrwxr-x hadoop hadoop Jun : config
drwxrwxr-x hadoop hadoop Apr : lib
-rw-rw-r-- hadoop hadoop Aug LICENSE.txt
drwxrwxr-x hadoop hadoop Aug modules
-rw-rw-r-- hadoop hadoop Aug NOTICE.txt
drwxrwxr-x hadoop hadoop Apr : plugins
-rw-rw-r-- hadoop hadoop Aug README.textile
-rw-rw-r-- hadoop hadoop Jul : requests
[hadoop@master elasticsearch-2.4.]$ cat requests
{ "index" : { "_index" : "zhouls", "_type" : "user", "_id" : "" } }
{ "name" : "mayun" , "age" : "" }
{ "update" : { "_index" : "zhouls", "_type" : "user", "_id" : "" } }
{ "doc" : { "age" : }}
[hadoop@master elasticsearch-2.4.]$ curl -XPOST http://master:9200/_bulk --data-binary @requests
{"took":,"errors":false,"items":[{"index":{"_index":"zhouls","_type":"user","_id":"","_version":,"_shards":{"total":,"successful":,"failed":},"status":}},{"update":{"_index":"zhouls","_type":"user","_id":"","_version":,"_shards":{"total":,"successful":,"failed":},"status":}}]}[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
得到
官网
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html