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

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

问题描述

我最近升级到了Elasticsearch版本6.1.1,现在我无法从json文件中批量索引文档. Wehn我以内联方式进行操作,效果很好.这是文档的内容:

I recently upgraded to elasticsearch version 6.1.1 and now I can't bulk index documents from a json file. Wehn 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 6.1.1中引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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