打赏

Elasticsearch之CURL命令的bulk批量操作

 

 

 

   大家,也可去看看我下面的博客

Elasticsearch之批量操作bulk

 

 

 

 

 

 

 

   官网上,是举例了新建一个requests文件。

 

[hadoop@master elasticsearch-2.4.0]$ pwd
/home/hadoop/app/elasticsearch-2.4.0
[hadoop@master elasticsearch-2.4.0]$ ll
total 48
drwxrwxr-x 2 hadoop hadoop  4096 Apr 21 14:19 bin
drwxrwxr-x 3 hadoop hadoop  4096 Jun 30 09:33 config
drwxrwxr-x 2 hadoop hadoop  4096 Apr 21 14:19 lib
-rw-rw-r-- 1 hadoop hadoop 11358 Aug 24  2016 LICENSE.txt
drwxrwxr-x 5 hadoop hadoop  4096 Aug 29  2016 modules
-rw-rw-r-- 1 hadoop hadoop   150 Aug 24  2016 NOTICE.txt
drwxrwxr-x 5 hadoop hadoop  4096 Apr 22 08:49 plugins
-rw-rw-r-- 1 hadoop hadoop  8700 Aug 24  2016 README.textile
[hadoop@master elasticsearch-2.4.0]$ vim requests

 

 

 

{ "index" : { "_index" : "zhouls", "_type" : "user", "_id" : "6" } }
{ "name" : "mayun" , "age" : "51" }
{ "update" : { "_index" : "zhouls", "_type" : "user", "_id" : "6" } }
{ "doc" : { "age" : 52 }}

 

 

 

 

 

  然后,执行批量操作

[hadoop@master elasticsearch-2.4.0]$ pwd
/home/hadoop/app/elasticsearch-2.4.0
[hadoop@master elasticsearch-2.4.0]$ ll
total 52
drwxrwxr-x 2 hadoop hadoop  4096 Apr 21 14:19 bin
drwxrwxr-x 3 hadoop hadoop  4096 Jun 30 09:33 config
drwxrwxr-x 2 hadoop hadoop  4096 Apr 21 14:19 lib
-rw-rw-r-- 1 hadoop hadoop 11358 Aug 24  2016 LICENSE.txt
drwxrwxr-x 5 hadoop hadoop  4096 Aug 29  2016 modules
-rw-rw-r-- 1 hadoop hadoop   150 Aug 24  2016 NOTICE.txt
drwxrwxr-x 5 hadoop hadoop  4096 Apr 22 08:49 plugins
-rw-rw-r-- 1 hadoop hadoop  8700 Aug 24  2016 README.textile
-rw-rw-r-- 1 hadoop hadoop   201 Jul  1 11:25 requests
[hadoop@master elasticsearch-2.4.0]$ cat requests 
{ "index" : { "_index" : "zhouls", "_type" : "user", "_id" : "6" } }
{ "name" : "mayun" , "age" : "51" }
{ "update" : { "_index" : "zhouls", "_type" : "user", "_id" : "6" } }
{ "doc" : { "age" : 52 }}
[hadoop@master elasticsearch-2.4.0]$ curl -XPOST http://master:9200/_bulk --data-binary @requests
{"took":506,"errors":false,"items":[{"index":{"_index":"zhouls","_type":"user","_id":"6","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"status":201}},{"update":{"_index":"zhouls","_type":"user","_id":"6","_version":2,"_shards":{"total":2,"successful":2,"failed":0},"status":200}}]}[hadoop@master elasticsearch-2.4.0]$ 
[hadoop@master elasticsearch-2.4.0]$ 
[hadoop@master elasticsearch-2.4.0]$ 

 

 

 

   得到

 

 

 

 

 

 

官网

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

 

posted @ 2017-07-01 11:34  大数据和AI躺过的坑  阅读(4799)  评论(0编辑  收藏  举报