当前位置: 代码迷 >> 综合 >> 解决VScode 中用restful向ES中批量写入数据时,提示 “The bulk request must be terminated by a newline [\n]“
  详细解决方案

解决VScode 中用restful向ES中批量写入数据时,提示 “The bulk request must be terminated by a newline [\n]“

热度:26   发布时间:2024-01-19 08:32:37.0

通常用的head都是:@head =content-type: application/json
应用bulk进行写入时,要替换成:@head_bulk =Content-Type: application/x-ndjson

例如:

PUT http://49.235.228.196:9211/news/_bulk
{
   {head_bulk}}{"index":{"_index":"news"}}
{"author":"John Michael","published":"2018-07-08","title":"Tesla is flirting with its lowest close in over 1 1/2 years (TSLA)","topic":"automobile","views":"431"}
{"index":{"_index":"news"}}
{"author":"John Michael","published":"2018-07-22","title":"Tesla to end up like Lehman Brothers (TSLA)","topic":"automobile","views":"1921"}
{"index":{"_index":"news"}}
{"author":"John Michael","published":"2018-07-29","title":"Tesla (TSLA) official says that they are going to release a new self-driving car model in the coming year","topic":"automobile","views":"1849"}
{"index":{"_index":"news"}}//最后要有一个空行
  相关解决方案