【发布时间】:2019-04-27 10:06:22
【问题描述】:
我想将包含我的my_docs.json 的文档插入到我的弹性搜索索引中。我的 json 文件如下所示:
{"_index":"twitter","_type":"_doc","_id":"v8XSJ2cB_TizemYYi5mW","_score":1,"_source":{"user":"me","c":"2018-11-18T17:16:08.953Z","content":"this is cool stuff"}}
{"_index":"twitter","_type":"_doc","_id":"x8XbJ2cB_TizemYYxZmf","_score":1,"_source":{"user":"you","c":"2018-11-18T17:26:13.634Z","content":"this is some other cool stuff"}}
我试过了:curl -XPUT 'http://localhost:9200/twitter/_bulk?pretty&refresh' -H "Content-Type: application/json" -d @my_docs.json
twitter 是我的索引。
我收到一个错误:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
},
"status" : 400
}
我在文件末尾添加了一个“\n”,但问题仍然存在,并且出现了同样的错误。
我该如何解决这个问题?
【问题讨论】:
-
您可能需要将内容类型指定为数据/二进制。
标签: json elasticsearch curl