【问题标题】:Error loading sample dataset in Elastic search在弹性搜索中加载示例数据集时出错
【发布时间】:2017-02-15 01:53:44
【问题描述】:

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

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

【问题讨论】:

  • 您确定accounts.json 文件在您当前的文件夹中吗?你能显示它包含的前几行吗?
  • 我只从 ES 站点下载了示例 json,所以我认为不会有任何错误。
  • 你错过了应该是{"index":{"_id":"742"}}的第一行
  • 我从 ES 文档下载的 json 文件只有上面只是来自 accounts.json 的随机数据行你可以从这个链接elastic.co/guide/en/elasticsearch/reference/current/…查看原始 json 文件 urself
  • 很奇怪,因为它非常适合我。您在 elasticsearch 日志中看到了什么?

标签: elasticsearch


【解决方案1】:

这是因为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 不存在的文件时收到相同的错误消息。

【讨论】:

    【解决方案2】:

    如果您使用的是 Mac OS X > Mojave / Catalina

    请检查您的终端权限。

    1 下拉 Apple 菜单并选择“系统偏好设置”

    2 选择“安全和隐私”控制面板

    3 现在选择“隐私”选项卡,然后从左侧菜单中选择“全盘 访问”

    4 单击首选项面板左下角的锁定图标,然后 使用管理员级别登录进行身份验证

    5 现在单击 [+] 加号按钮以添加具有完整磁盘访问权限的应用程序

    6 导航到 /Applications/Utilities/ 文件夹并选择“终端”授予 具有全盘访问权限的终端

    7 重新启动终端,“Operation not allowed”错误信息将消失

    • 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.

    【讨论】:

      【解决方案3】:

      检查您是否有足够的可用内存,超过 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)

      【讨论】:

        猜你喜欢
        • 2015-10-08
        • 2015-10-21
        • 1970-01-01
        • 2020-08-16
        • 2020-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多