批量请求在Elasticsearch 6.1.1中引发错误

我最近升级到了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中发送数据,效果很好。我尝试将换行符以及换行符添加到文件末尾。似乎不起作用。

回答:

在JSON文件的末尾添加 行并保存文件,然后尝试运行以下命令

curl -XPOST localhost:9200/subscribers/ppl/_bulk?pretty --data-binary @customers_full.json -H 'Content-Type: application/json'

我希望它对您有用。

以上是 批量请求在Elasticsearch 6.1.1中引发错误 的全部内容, 来源链接: utcz.com/qa/422348.html

回到顶部