温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Elasticsearch批量插入数据

发布时间:2020-05-21 23:07:27 来源:网络 阅读:4860 作者:QuiteQuiet 栏目:数据库

Elasticsearch批量插入数据

使用bulk批量操作数据库

1. 创建批量操作文件

格式:

{"index":{"_index":"home","_type":"home",""_id":"2"}}
{"id": 2, "location": "南京市栖霞区马群街道29号", "money": 3000, "area":80, "type": "三居室", "style": "整租"}

第一行指定请求与索引和类型,可以选择的请求有"create","index","delete","ubdate",
"_index"指定索引名,"_type"指定类型名,"_id"指定id

第二行指定插入的内容.

如request.json:

{"index":{"_index":"home","_type":"home","_id":"2"}}
{"id": 2, "location": "南京市栖霞区马群街道29号", "money": 3000, "area":80, "type": "三居室", "style": "整租"}
{"index":{"_index":"home","_type":"home","_id":"3"}}
{"id": 3, "location": "南京市玄武区山西路门路29号", "money": 400, "area":15, "type": "四居室", "style": "合租"}
{"index":{"_index":"home","_type":"home","_id":"4"}}
{"id": 4, "location": "南京市秦淮区山北京东路29号", "money": 500, "area":14, "type": "三居室", "style": "合租"}
{"index":{"_index":"home","_type":"home","_id":"5"}}
{"id": 5, "location": "南京市秦淮区新街口29号", "money": 450, "area":16, "type": "四居室", "style": "合租"}
2.执行批量操作文件

在数据库根目录执行:

curl -XPUT 'localhost:9200/_bulk' -H "Content-Type: application/json" --data-binary @request.json

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI