zoukankan      html  css  js  c++  java
  • ElasticSearch _bulk批量插入报错

    一、现象

    今天在 ElasticSearch 批量插入时:

    POST /customer/external/_bulk
    {
      "index":{"_id":"1"}
    }
    {
      "name":"John"
    }
    {
      "index":{"_id":"2"}
    }
    {
      "name":"tom"
    }

    出现了这样的错误:

    {
      "error": {
        "root_cause": [
          {
            "type": "json_e_o_f_exception",
            "reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2eeea373; line: 1, column: 1])
     at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2eeea373; line: 1, column: 3]"
          }
        ],
        "type": "json_e_o_f_exception",
        "reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2eeea373; line: 1, column: 1])
     at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@2eeea373; line: 1, column: 3]"
      },
      "status": 500
    }

    二、原因

    bulk api对json语法有严格的要求,每个json串不能换行,只能放到一行,同时一个json串和一个json串之间必须要换行,否则会出现如上错误

    三、解决

    POST /customer/external/_bulk
    {"index":{"_id":"1"}}
    {"name":"John"}
    {"index":{"_id":"2"}}
    {"name":"tom"}

    插入成功:

  • 相关阅读:
    跨域与跨域访问
    bootstrap.min.css.map作用
    CSS
    http协议
    djngo未整理
    redis安装及配置
    git 基础
    yum安装报错
    Go语言与区块链开发(转载)
    electron实现MessageBox
  • 原文地址:https://www.cnblogs.com/houchen/p/14152556.html
Copyright © 2011-2022 走看看