【问题标题】:How to bulk insert 600MB large json file to elasticsearch?如何将 600MB 大 json 文件批量插入到 elasticsearch?
【发布时间】:2020-01-08 01:43:51
【问题描述】:

我正在尝试将 600MB Json 文件(将来可能会放大)插入到 elasticsearch。 但是,我得到以下错误,

Error: "toString()" failed

我正在使用 stream-json npm 但没有运气:( 做这个的最好方式是什么? 我正在考虑分块,但如果有更好的方法,那就太好了

var makeBulk = function(csList, callback){
  const pipeline = fs.createReadStream('./CombinedServices_IBC.json').pipe(StreamValues.withParser());
  while()
  pipeline.on('data', data => {
    for(var index in data.value.features){
      bulk.push(
        { index: {_index: 'combinedservices1', _type: '_doc', _id: data.value.features[index].properties.OBJECTID } },
        {
          'geometry': data.value.features[index].geometry,
          'properties': data.value.features[index].properties
        }
      );
    }
    callback(bulk);

  });

}

【问题讨论】:

  • 您是如何将大型 GeoJson 上传到 ElasticSearch 的?

标签: json node.js elasticsearch npm kibana


【解决方案1】:

有一个用于这种用例的工具 Elasticdump(https://github.com/taskrabbit/elasticsearch-dump)

安装elasticsearch-dump

npm install elasticdump -g
elasticdump

将 Json 导入 ES

elasticdump \
  --input=./CombinedServices_IBC.json \
  --output=http://127.0.0.1:9200/my_index \
  --type=alias

【讨论】:

    【解决方案2】:

    不要插入600MB的bulk,默认bulk queue最多可以保留200个bulk inn JVM Heap Space——想象一下如果每个都是600MB,你会遇到OOM和GC问题

    参考https://www.elastic.co/guide/en/elasticsearch/guide/current/bulk.html#_how_big_is_too_big;示例 logstash elasticsearch 输出插件最多发送20Mb

    【讨论】:

      猜你喜欢
      • 2016-08-11
      • 1970-01-01
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      相关资源
      最近更新 更多