将数据发送到Elasticsearch时出错

时间:2018-05-30 11:45:17

标签: elasticsearch

使用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 个答案:

答案 0 :(得分:0)

您提供了错误的文件名。该文件的名称为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

这假定文件位于当前目录中。