【问题标题】:Elasticsearch mapper_parsing_exceptionElasticsearch mapper_parsing_exception
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

    • 是的,我的错误是因为 curl 找不到 test.json。
    猜你喜欢
    • 2017-01-22
    • 2019-07-18
    • 2018-12-03
    • 1970-01-01
    • 2018-01-22
    • 2016-04-07
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多