ElasticSearch to MS SQL Server



我们正在为内部应用程序监控创建每日索引。我们每天收到近30万条记录,并且正在使用Kibana实时分析这些记录。

现在我们想将数据从elasticsearch转移到MSSQLServer。使用nodejs弹性搜索模块,我可以将数据移动到MSSQL Server中。

然而,它可以对大约1000个记录的小卷进行。由于我想从elasticsearch中读取所有记录并将其转储到MSSQL服务器,有更好的方法吗?

我能够使用弹性搜索滚动功能实现同样的功能。有关详细信息,请参阅链接https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference-2-2.html#api-滚动-2-2

此处的示例代码以防链接变为非活动

var allTitles = [];
// first we do a search, and specify a scroll timeout
client.search({
  index: 'myindex',
  // Set to 30 seconds because we are calling right back
  scroll: '30s',
  search_type: 'scan',
  fields: ['title'],
  q: 'title:test'
}, function getMoreUntilDone(error, response) {
  // collect the title from each response
  response.hits.hits.forEach(function (hit) {
    allTitles.push(hit.fields.title);
  });
  if (response.hits.total !== allTitles.length) {
    // now we can call scroll over and over
    client.scroll({
      scrollId: response._scroll_id,
      scroll: '30s'
    }, getMoreUntilDone);
  } else {
    console.log('every "test" title', allTitles);
  }
});

相关内容

最新更新