Elasticsearch:批量请求在Elasticsearch 6.1.1中引发错误 [英] Elasticsearch: Bulk request throws error in Elasticsearch 6.1.1

查看:100
本文介绍了Elasticsearch:批量请求在Elasticsearch 6.1.1中引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到Elasticsearch版本6.1.1,现在我无法从JSON文件批量索引文档。当我内联完成时,它可以正常工作。以下是文档的内容:

I recently upgraded to Elasticsearch version 6.1.1 and now I can't bulk index documents from a JSON file. When I do it inline, it works fine. Here are the contents of the document:

{"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中发送数据,它可以正常工作。我尝试将换行符以及换行符添加到文件末尾。似乎无效。

It works fine if I send the data inline and in Elasticsearch 5.x. I tried adding newlines as well as the newline character to the end of the file. Doesn't seem to work.

推荐答案

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

Add empty line at the end of the JSON file and save the file and then try to run the below command

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

我希望对你来说很好。

这篇关于Elasticsearch:批量请求在Elasticsearch 6.1.1中引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆