您好我正在尝试加载示例数据集referring elastic search docs但是当我尝试运行指令命令时,我收到以下错误。我已阅读所有文件,但我无法解决。
$ curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
Warning: Couldn't read data from file "accounts.json", this makes an empty
Warning: POST.
{
"error" : {
"root_cause" : [ {
"type" : "parse_exception",
"reason" : "Failed to derive xcontent"
} ],
"type" : "parse_exception",
"reason" : "Failed to derive xcontent"
},
"status" : 400
}
accounts.json中的前几行是: -
{"account_number":736,"balance":28677,"firstname":"Rogers","lastname":"Mcmahon","age":21,"gender":"F","address":"423 Cameron Court","employer":"Brainclip","email":"rogersmcmahon@brainclip.com","city":"Saddlebrooke","state":"FL"}
{"index":{"_id":"743"}}
{"account_number":743,"balance":14077,"firstname":"Susana","lastname":"Moody","age":23,"gender":"M","address":"842 Fountain Avenue","employer":"Bitrex","email":"susanamoody@bitrex.com","city":"Temperanceville","state":"TN"}
{"index":{"_id":"748"}}
{"account_number":748,"balance":38060,"firstname":"Ford","lastname":"Branch","age":25,"gender":"M","address":"926 Cypress Avenue","employer":"Buzzness","email":"fordbranch@buzzness.com","city":"Beason","state":"DC"}
{"index":{"_id":"750"}}
我还提到了Bulk API doc of ES
我能够创建单个索引,但由于未知原因,我无法索引批量文档。
答案 0 :(得分:2)
这是因为accounts.json
文件无法读取,因为它具有错误的权限/所有者,或者因为它不在您当前的工作目录中。
首先,在您的文件系统上找到该文件,检查它是否肯定在您当前的工作目录中,键入ls -al accounts.json
(如果您使用的是Windows,则应该使用dir accounts.json /Q
)和确保它具有读取权限,然后通过curl命令提供完整路径,例如:
curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary "@/home/user/accounts.json"
我确定这是问题的原因是因为当我尝试POST一个不存在的文件时,我收到相同的错误消息。
答案 1 :(得分:0)
如果您使用的是Mac OS X> Mojave / Catalina
请检查您的终端权限。
1下拉Apple菜单,然后选择“系统偏好设置”
2选择“安全和隐私”控制面板
3现在选择“隐私”选项卡,然后从左侧菜单中选择“完整磁盘” 访问”
4单击首选项面板左下角的锁定图标,然后单击。 使用管理员级别的登录信息进行身份验证
5现在单击[+]加号按钮以添加具有完全磁盘访问权限的应用程序
6导航到/ Applications / Utilities /文件夹,然后选择“ Terminal”进行授予 具有完全磁盘访问权限的终端
7重新启动终端,“不允许操作”错误消息将消失
On completion of these steps please navigate to the dir where you have placed your json file and try to run the associated curl command.
答案 2 :(得分:0)
检查是否有足够的可用内存(超过20-30 GB)
我正试图将示例数据(电子商务订单,航班,网络日志)加载到我的kibana中。我遇到了一些错误。 显示的日志
[o.e.c.r.a.DiskThresholdMonitor] high disk watermark [90%] exceeded on [/Users/xyz/Installs/ElasticSearch/elasticsearch-7.9.3/data/nodes/0] free: 15.1gb[6.4%], shards will be relocated away from this node; currently relocating away shards totalling [0] bytes; the node is expected to continue to exceed the high disk watermark when these relocations are complete
我释放了额外的20 GB,然后它起作用了。 请检查是否有足够的内存(不确定内存大小,可能超过20-30 GB)