Linux命令同步文件到ES
文件
{"index":{"_index":"dmfun","_type":"user"}} {"uid":"s1","name":"s某","address":"sss镇","age":20,"sex":1,"createdt":"2021-01-19"}
命令
curl -H "Content-Type:application/json" -XPOST http://localhost:9200/_bulk --data-binary @2.json -o out.dat
结果
[es@bogon tools]$ curl -H "Content-Type:application/json" -XPOST http://localhost:9200/_bulk --data-binary @2.json -o out.dat % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 188 236 118 236 0 140 12796 7591 --:--:-- --:--:-- --:--:-- 5647
日志
{"took":15,"errors":false,"items":[{"index":{"_index":"dmfun","_type":"user","_id":"9ZCdGXcBASnacUsZwUJi","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":82541,"_primary_term":7,"status":201}}]}
如果报错
The bulk request must be terminated by a newline [\n]
则是windows文件格式问题,回车不被识别,在linux里面新建的文件就可以