【发布时间】:2016-05-05 12:27:18
【问题描述】:
我是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 的替代解决方案。
【问题讨论】:
标签: python json elasticsearch logstash