Elasticsearch 根据 json 文件 bulk 批量导入数据

网友投稿 371 2022-11-01

Elasticsearch 根据 json 文件 bulk 批量导入数据

生成 json 文件

没有指定 index :

cat /tmp/jenkins_executor.json {"index":{}} {"date":1656467701,"Label_Group":"CI_Build_Label","Label":"sse_build_sh","busyExecutors":9,"idleExecutors":0,"totalExecutors":9} {"index":{}} {"date":1656467701,"Label_Group":"CI_Test_Label","Label":"t20_silicon_x86_ubuntu","busyExecutors":38,"idleExecutors":1,"totalExecutors":38} {"index":{}} {"date":1656467701,"Label_Group":"CI_Test_Label","Label":"i20_silicon_x86_ubuntu","busyExecutors":16,"idleExecutors":0,"totalExecutors":16} {"index":{}} {"date":1656467701,"Label_Group":"CI_Test_Label","Label":"t10_silicon_x86_ubuntu","busyExecutors":13,"idleExecutors":3,"totalExecutors":16}

指定 index :

{"index": {"_index": "store_suggest"}} {"name": "意美家居饰品"} {"index": {"_index": "store_suggest"}} {"name": "季品特产店"} {"index": {"_index": "store_suggest"}} {"name": "逸居饰品生活馆"} {"index": {"_index": "store_suggest"}} {"name": "雕刻人生"} {"index": {"_index": "store_suggest"}} {"name": "安美装饰画铺"} {"index": {"_index": "store_suggest"}} {"name": "鑫艺坊"} {"index": {"_index": "store_suggest"}} {"name": "艺聚堂"} {"index": {"_index": "store_suggest"}} {"name": "三生石工艺坊批发店"}

导入数据

使用bulk api进行批量操作,但是需要注意文件的格式,否则会出现问题参考中提示的\n问题。以下是可执行的curl:

curl -XPOST -H 'Content-Type: application/json' --data-binary @/tmp/jenkins_executor.json

课外

github 上有一个现成的 json 数据文件,可以用来做测试:测试数据原文链接

问题参考:

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Jira Python REST API 使用
下一篇:SDN北向接口标准化简介以及相关标准化进展
相关文章

 发表评论

暂时没有评论,来抢沙发吧~