Error loading sample dataset in Elastic search

匿名 (未验证) 提交于 2019-12-03 01:35:01

问题:

Hi I am trying to load a sample data set referring elastic search docs but when I am trying to run the instructed command, I am getting the below error. I have read all documents but I am unable to resolve it.

$ 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     } 

First few lines in accounts.json is:-

{"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"}} 

I have also referred Bulk API doc of ES

I am able to create single index but due to unknown reasons I am not able to index bulk documents.

回答1:

This is because the accounts.json file is not available for reading, either because it has the wrong permissions/owner or because it is not in your current working directory.

First, locate the file on your filesystem, to check if it is definitely in your current working dir, type ls -al accounts.json (if you're using windows you should probably use dir accounts.json /Q) and make sure it has read permissions, then provide the full path via the curl command, for example:

curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary "@/home/user/accounts.json" 

The reason I'm sure this is the issue is because I get the same error message when I try to POST a non-existing file.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!