弹性搜索 mapper_parsing_exception

Elasticsearch mapper_parsing_exception

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

在我看来,问题是 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 文件并从中读取数据。