ElasticSearch大批量数据入库

1.bulk批量导入数据

 
 
curl 172.17.1.15:9200/_bulk?pretty --data-binary @E:\Bin\Debug\testdata\437714060.json
curl 172.17.1.15:9200/_bulk?pretty --data-binary @E:\Bin\Debug\testdata\743719428.json
curl 172.17.1.15:9200/_bulk?pretty --data-binary @E:\Bin\Debug\testdata\281679894.json
curl 172.17.1.15:9200/_bulk?pretty --data-binary @E:\Bin\Debug\testdata\146257480.json
curl 172.17.1.15:9200/_bulk?pretty --data-binary @E:\Bin\Debug\testdata\892018760.json
但问题是这方法是先定义一定格式的json文件,然后再用curl命令去执行Elasticsearch的_bulk来批量插入,所以得把数据写进json文件,然后再通过批处理,执行文件插入数据, 另外在生成json文件,文件不能过大,过大会报错,所以建议生成10M一个文件

2. github上找到了一个数据导入导出工具

github上找到了一个数据导入导出工具,算是基本上解决了这个问题,直接把数据从原来的index里面取出来然后重新录入到新的index里面,这样省去了数据解析的过程,节约了不少时间。

下面是问题的解决步骤:

首先安装一下elasticsearch-knapsack(数据导入导出工具)

  1. ./bin/plugin -install knapsack -url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-knapsack/1.5.2.0/elasticsearch-knapsack-1.5.2.0-plugin.zip  

然后可以通过导出命令导出json格式的数据到系统中的某个文件夹(导出某个index中的数据到指定路径)
  1. curl -XPOST 'localhost:9200/test/_export?path=/tmp/myarchive.zip'  

然后运用导入命令将数据导入进elasticsearch里面
[html] view plain copy
  1. curl -XPOST 'localhost:9200/test/test/_import?path=/tmp/myarchive.zip' 

以下是github地址:

  1. https://github.com/jprante/elasticsearch-knapsack 


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Soyoger

听说打赏的都进了福布斯排行榜。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值