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
作者:大数据和人工智能躺过的坑
出处:http://www.cnblogs.com/zlslch/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
如果您认为这篇文章还不错或者有所收获,您可以通过右边的“打赏”功能 打赏我一杯咖啡【物质支持】,也可以点击右下角的【好文要顶】按钮【精神支持】,因为这两种支持都是我继续写作,分享的最大动力!