【ElasticSearch】踩坑 關於bulk操作報錯
阿新 • • 發佈:2021-09-16
【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}}}
建立成功