Elasticsearch mapper_parsing_exception

时间:2016-05-05 12:27:19

标签: python json elasticsearch logstash

我是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开放替代解决方案。

1 个答案:

答案 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文件并从中读取数据。