【问题标题】:Error while sending data into Elasticsearch将数据发送到 Elasticsearch 时出错
【发布时间】:2018-05-30 11:45:16
【问题描述】:

在使用 Elasticsearch 通过 curl 命令加载数据集时->

curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/shakespeare/doc/_bulk?pretty" --data-binary @$shakespeare_6.0

遇到以下警告->

Warning: Couldn't read data from file "$shakespeare_6.0", this makes an empty
Warning: POST.
{
  "error" : {
    "root_cause" : [
      {
        "type" : "parse_exception",
        "reason" : "request body is required"
      }
    ],
    "type" : "parse_exception",
    "reason" : "request body is required"
  },
  "status" : 400
}

我的数据是:

    {"index":{"_index":"shakespeare","_id":0}}
    {"type":"act","line_id":1,"play_name":"Henry IV", "speech_number":"","line_number":"","speaker":"","text_entry":"ACT I"}

此警告的根本原因是什么?我使用的是 64 位 Windows 10。

另外,请告诉我将数据发送到弹性搜索的不同方式是什么?我是菜鸟。

【问题讨论】:

标签: elasticsearch


【解决方案1】:

您提供了错误的文件名。该文件的名称是shakespeare_6.0.json,而不是$shakespeare_6.0。这是正确的命令:

curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/shakespeare/doc/_bulk?pretty" --data-binary @shakespeare_6.0.json

这假定文件在当前目录中。

【讨论】:

  • 给您带来的不便,我深表歉意。我实际上只输入了“shakespeare_6.0.json”。
  • 它正在使用:- curl -H "Content-Type: application/json" -XPOST "localhost:9200/bank/_doc/_bulk?pretty&refresh" --data-binary "@shakespeare_6. 0.json" 但是现在它显示了这个错误。我正在添加 sn-p :{“index”:{“_index”:“shakespeare”,“_type”:“_doc”,“_id”:“111395”,“status”:400,“error”:{“ type" : "illegal_argument_exception", "reason" : "拒绝对 [shakespeare] 的映射更新,因为最终映射将有超过 1 种类型:[_doc, doc]" } } }
  • 您应该删除doc 之前的下划线。您现在正在推送到索引 bank 而不是 shakespeare
  • 非常感谢您的帮助。这个命令对我有用: curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/shakespeare/doc/_bulk?pretty&refresh" --data-binary "@shakespeare_6.0.json"跨度>
  • 很高兴为您提供帮助,欢迎来到 Stack Overflow。如果此答案或任何其他答案解决了您的问题,请将其标记为已接受。
猜你喜欢
  • 1970-01-01
  • 2016-05-14
  • 1970-01-01
  • 1970-01-01
  • 2021-05-06
  • 1970-01-01
  • 1970-01-01
  • 2018-05-07
  • 2016-11-05
相关资源
最近更新 更多