其他分享
首页 > 其他分享> > 【ElasticSearch】踩坑 关于bulk操作报错

【ElasticSearch】踩坑 关于bulk操作报错

作者:互联网

【ElasticSearch】踩坑 关于bulk操作报错


1.问题

想要执行批量插入操作

POST /customer/external/_bulk
{"create":{"_id":"1"}}
{
  "key_id":"url_https_18560751222",
  "nodealias": "baidu",
  "taskFinishTime":"1630857697326",
  "result":
    {
      "http_request":
      {
        "responseTime":89.0
      }
    }
}
{"create":{"_id":"2"}}
{
  "key_id":"url_https_18560751211",
  "nodealias": "bing",
  "taskFinishTime":"1630857697300",
  "result":
  {
    "http_request":
    {
      "responseTime":109.0
    }
  }
}

报错:

json_e_o_f_exception

"Unexpected end-of-input: expected close marker for Object (start marker at [Source: (ByteArrayInputStream); line: 1, column: 1])\n at [Source: (ByteArrayInputStream); line: 1, column: 2]"

或者

illegal_argument_exception

Malformed action/metadata line [3], expected START_OBJECT but found [VALUE_STRING]


2.正确写法

万万没想到,_bulk的操作,行为和请求体数据 都是不能换行的。。

POST /customer/external/_bulk
{"create":{"_id":"1"}}
{"key_id":"url_https_18560751222","nodealias": "baidu","taskFinishTime":"1630857697326","result":{"http_request":{"responseTime":89.0}}}
{"create":{"_id":"2"}}
{"key_id":"url_https_18560751211","nodealias": "bing","taskFinishTime":"1630857697300","result":{"http_request":{"responseTime":109.0}}}

创建成功

标签:https,create,taskFinishTime,bulk,ElasticSearch,responseTime,报错,id
来源: https://www.cnblogs.com/musecho/p/15293815.html