当前位置: 首页 > 面试题库 >

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

郎鸿雪
2023-03-14
问题内容

我最近升级到了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'

我希望它对您有用。



 类似资料:
  • 一种写法同时支持 Curl 和 Swoole use \Yurun\Util\YurunHttp\Co\Batch; use \Yurun\Util\HttpRequest; $result = Batch::run([ (new HttpRequest)->url('https://www.imiphp.com'), (new HttpRequest)->url('https:

  • 创建elasticsinkconnector时出现以下错误。 使用(" type.name"= '_doc '," input.data.format"= 'AVRO '," CONNECTOR . class " = ' io . confluent . connect . elasticsearch . elasticsearchsinkconnector '," tasks.max"= '1

  • 问题内容: 试图让批量更新在ES 1.0.1上运行。 我在邮递员内发布以下内容: URL 或以 请求正文 : 我已经尝试过,无论有没有。我总是 在使用数据进行创建时,它也做同样的事情: 更新资料 我已经在Mac,PC和Linux上尝试过此方法,但不断出现相同的错误。 问题答案: 即使我在最后一行上,我在最后一个json行之后也确实要有完整的回车符。 以下工作: 因此,在该行下方需要有一个空行。

  • 批量调用 TOP 接口 参数 名称 类型 是否可选 含义 options Object 选项 options.query Array 请求参数数组 options.query[].topOptions Object 请求参数 options.query[].topOptions.method String TOP 接口名称 options.success Function optional 调用成

  • web3.BatchRequest类用来创建并执行批请求。 调用: new web3.BatchRequest() new web3.eth.BatchRequest() new web3.shh.BatchRequest() new web3.bzz.BatchRequest() 参数: 无 返回值: 一个对象,具有如下方法: add(request): 将请求对象添加到批调用中 execut

  • 问题内容: 我已经实现了当前的一组路由(例如): 他们工作得很漂亮。现在,假设我要为同一API实现“批处理终结点”。它看起来应该像这样: 身体应该像这样: 为此,我想知道如何调用播放框架路由器来传递这些请求?我打算使用与单元测试建议类似的方法: 通过进入的源代码,您会发现如下所示: 所以我的问题是:与复制上面的代码相比,用Play做到这一点的方式是否更简单(我不反对将Scala和Java混合使用)