我最近升级到了Elasticsearch版本6.1.1,现在不能批量索引JSON文件中的文档。当我以内联方式执行时,它工作得很好。以下是文档的内容:
{"index" : {}}
{"name": "Carlson Barnes", "age": 34}
{"index":{}}
{"name": "Sheppard Stein","age": 39}
{"index":{}}
{"name": "Nixon Singleton","age": 36}
{"index":{}}
{"name": "Sharron Sosa","age": 33}
{"index":{}}
{"name": "Kendra Cabrera","age": 24}
{"index":{}}
{"name": "Young Robinson","age": 20}
当我运行此命令时,
curl -XPUT 'localhost:9200/subscribers/ppl/_bulk?pretty' -H 'Content-Type: application/json' -d @customers_full.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
如果我以内联方式并在Elasticsearch 5.x中发送数据,它就能正常工作。我尝试在文件末尾添加换行符和换行符。似乎不管用。
发布于 2018-02-02 17:53:43
错误很明显:
The bulk request must be terminated by a newline [\n]
因此,您只需在customers_full.json
文件的末尾添加一个换行符,就可以了。
发布于 2018-05-31 04:45:54
我遇到了同样的问题,花了几个小时添加和删除换行符,直到有人指出我输入了错误的文件名……因此,请注意,如果文件实际上不存在,curl将抛出相同的错误,这使得这非常令人困惑。
发布于 2018-10-10 03:22:31
在JSON文件内的行尾按Enter键,然后再次运行该命令。
curl -H "Content-Type: application/x-ndjson" -XPOST 'localhost:9200/customers/personal/_bulk?pretty&refresh' --data-binary @"generated.json"
https://stackoverflow.com/questions/48579980
复制相似问题