我是elasticsearch
的新手并试图将json数据导入其中。我的数据看起来像(logstash);
{ "test": "lorem", "test1": "1231", "test2": "asdasda" }
{ "test": "ipsum", "test1": "5644", "test2": "ghnghn" }
...
我也尝试了一些变体,如:
[{ "test": "lorem", "test1": "1231", "test2": "asdasda" },
{ "test": "ipsum", "test1": "5644", "test2": "ghnn" }]
和
{"tests":[{ "test": "lorem", "test1": "1231", "test2": "asdasda" },
{ "test": "ipsum", "test1": "5644", "test2": "ghnn" }]}
当我运行post
命令时,
"curl -XPOST "http://localhost:9200/_bulk" -d @test.json"
我得到了:
Warning: Couldn't read data from file "test.json", this makes an empty POST.
{"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derivexcontent"}],
"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400}
我也使用Python开放替代解决方案。
答案 0 :(得分:0)
在我看来,问题是curl
无法找到test.json
文件,这会进一步导致上游POST处理程序出错。
我尝试使用不存在的文件,并从curl
$ curl -XPOST http://localhost:12345/bogus -d @bogusfile
Warning: Couldn't read data from file "bogusfile", this makes an empty POST.
确保curl
实际上找到test.json文件并从中读取数据。