elasticsearch - 在 Elasticsearch 中加载示例数据集时出错

标签 elasticsearch

您好,我正在尝试加载示例数据集 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
    }

enter image description here

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

我能够创建单个索引,但由于未知原因,我无法为批量文档编制索引。

最佳答案

这是因为 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"

我确定这是问题所在的原因是因为当我尝试发布一个不存在的文件时收到相同的错误消息。

关于elasticsearch - 在 Elasticsearch 中加载示例数据集时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39893964/

相关文章:

php - cURL 已安装,但仍然出现此错误 Elasticsearch-PHP 需要 cURL 或自定义 HTTP 处理程序

ruby-on-rails - Searchkick 异步更新

serialization - 将 Elasticsearch 结果返回为原始JSON

elasticsearch - elasticsearch 是不确定的吗?

elasticsearch - 加快ElasticSearch中的映射创建

azure - Elk Logstash 无法连接到事件中心 Azure

elasticsearch - 对Elastic Search中的索引进行搜索查询时引起不同结果的时区

exception - 增加 Elasticsearch 队列的大小?

node.js - 无法通过Kubernetes上的Node.Js连接到Elasticsearch(证书链中的自签名证书)

java - lucene,如何一起使用 SearcherManager 和 SearcherLifetimeManager