Elasticsearch映射器解析异常

2024-09-24 02:17:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我不熟悉elasticsearch,并尝试将json数据导入其中。我的数据看起来像(logstash)

{ "test": "lorem", "test1": "1231", "test2": "asdasda" }
{ "test": "ipsum", "test1": "5644", "test2": "ghnghn" }
...

我也尝试了一些变化,比如:

^{pr2}$

以及:

{"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打开了替代解决方案。在


Tags: to数据testjsonparsetypeexceptionelasticsearch
1条回答
网友
1楼 · 发布于 2024-09-24 02:17:35

在我看来,问题是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确实在查找测试.json文件并从中读取数据。在

相关问题 更多 >