我对elasticsearch很陌生,并试图将json数据导入其中。我的数据看起来像(日志);
{ "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打开了其他解决方案。
发布于 2016-05-05 12:45:31
在我看来,问题在于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文件并从中读取数据。
https://stackoverflow.com/questions/37050606
复制相似问题