gpt4 book ai didi

json - 在ElasticSearch上的批量请求返回消息 “The bulk request must be terminated by a newline”

转载 作者:行者123 更新时间:2023-12-03 00:49:49 26 4
gpt4 key购买 nike

我知道在StackOverflow上已经有类似的问题,但是没有一个可以解决我当前的问题。

我正在使用ElasticSearch 6.7.0,目前正在研究其教程。目前,我陷入了this step的困境,这需要我download存储在accounts.json文件中的一些示例数据。这是该文件的一小段:

{"index":{"_id":"988"}}
{"account_number":988,"balance":17803,"firstname":"Lucy","lastname":"Castro","age":34,"gender":"F","address":"425 Fleet Walk","employer":"Geekfarm","email":"lucycastro@geekfarm.com","city":"Mulino","state":"VA"}
{"index":{"_id":"990"}}
{"account_number":990,"balance":44456,"firstname":"Kelly","lastname":"Steele","age":35,"gender":"M","address":"809 Hoyt Street","employer":"Eschoir","email":"kellysteele@eschoir.com","city":"Stewartville","state":"ID"}
{"index":{"_id":"995"}}
{"account_number":995,"balance":21153,"firstname":"Phelps","lastname":"Parrish","age":25,"gender":"M","address":"666 Miller Place","employer":"Pearlessa","email":"phelpsparrish@pearlessa.com","city":"Brecon","state":"ME"}

该文件保存在路径 C:\Users\Me\Desktop\accounts.json中。

我按照教程中的说明运行了以下命令 :

PS C:\Users\Me\Downloads\curl-7.64.1-win64-mingw\bin> .\curl.exe -H "Content-Type: applicati lhost:9200/bank/_doc/_bulk?pretty&refresh" --data-binary "C:\Users\Me\Desktop\accounts.json"



我收到此错误消息:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
}
],
"type" : "illegal_argument_exception",
"reason" : "The bulk request must be terminated by a newline [\n]"
},
"status" : 400
}

为了解决这个问题,我转到文件的末尾,并按Enter插入了新行。但是,当我再次运行命令时,出现了相同的错误消息。

如何解决此问题?

最佳答案

我将accounts.json文件移到了运行curl.exe的目录中,并执行了以下命令:

.\curl.exe -H "Content-Type: applicati lhost:9200/bank/_doc/_bulk?pretty&refresh" --data-binary "@accounts.json"



这次,批量请求成功。

对于那些面临类似问题的用户,请记住按 Enter在文件末尾插入新行。如果这样不起作用,请尝试将文件移动到另一个目录。错误消息“批量请求必须以换行符终止”可能是 误导 -您的文件可能根本没有格式错误;也许由于各种原因根本无法定位或访问它。

关于json - 在ElasticSearch上的批量请求返回消息 “The bulk request must be terminated by a newline”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55511413/

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