gpt4 book ai didi

elasticsearch - 将JSON导入Elasticsearch时发生JsonParseException

转载 作者:行者123 更新时间:2023-12-02 22:17:41 27 4
gpt4 key购买 nike

我正在尝试将一些json数据导入我的elasticsearch实例中并得到以下错误:

{
"error" : "JsonParseException[Unexpected end-of-input: expected close marker for ARRAY (from [Source: [B@7110db07; line: 1, column: 0])\n at [Source: [B@7110db07; line: 1, column: 3]]",
"status" : 500
}

我正在使用在VirtualBox上运行的Ubuntu(14.04),这是我用来导入数据的命令:
url -XPOST 'localhost:9200/mydata/fields/_bulk?pretty' --data-binary @mydata.json

这是我的JSON示例:
[
{
"field1":"sometext",
"field2":"O",
"field3":"TEXT",
"field4":"CR",
"field5":"09:38.0",
"field6":"09:38.0",
"field7":"14:13.0",
"field8":"NULL",
"field9":"NULL",
"field10":"0",
"field11":"5",
"field12":"NULL",
"field13":"NULL",
"field14":"4",
"field15":"0"
},
{
"field1":"othertext",
"field2":"O",
"field3":"TEXT",
"field4":"CR",
"field5":"09:38.0",
"field6":"09:38.0",
"field7":"14:13.0",
"field8":"NULL",
"field9":"NULL",
"field10":"0",
"field11":"5",
"field12":"NULL",
"field13":"NULL",
"field14":"4",
"field15":"0"
},
]

是否可以使用批量API导入JSON数组?

最佳答案

您的json不必在批量API中包含换行符,因为API使用该换行符作为分隔符。从这里的Elasticsearch文档http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-bulk.html

Because this format uses literal \n's as delimiters, please be sure that the JSON actions and sources are not pretty printed.

关于elasticsearch - 将JSON导入Elasticsearch时发生JsonParseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24763937/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com