![](/img/trans.png)
[英]Node.JS - node-hbase Scan not working for more than 1000 records
[英]How to index more than 1000 documents in Elasticsearch with Node.js?
我已经构建了一个Node.js应用程序,该应用程序将API的结果作为文档索引到Elasticsearch中,但是ES仅索引总共1000个文档。 总共有超过10万个需要索引。 我似乎找不到任何地方可以解释如何将1k文档的摄取限制更改为其他数字。
这是我的代码示例,除了1k文档限制外,效果很好。
ATX_TRAFFIC_INCIDENTS.data.map(async traffic => (
await client.index({
index: 'atx_traffic',
id: traffic.traffic_report_id,
type: 'data',
body: {
traffic_report_id: traffic.traffic_report_id,
published_date: traffic.published_date,
issue_reported: traffic.issue_reported,
status_date: traffic.traffic_report_status_date_time,
status: traffic.traffic_report_status,
address: traffic.address,
latitude: traffic.latitude,
longitude: traffic.longitude,
location:
{
lat: traffic.latitude,
lon: traffic.longitude,
}
}
})
));
首先,没有内在原因可以将超过1000个文档插入ElasticSearch。 您的问题很有可能是由于在您的Promises上进行映射而引起的,这是一种反模式。
通过映射Promises,您无法在功能完成之前知道它们是否已解析。 您也无法对引发的任何错误做出反应。 你真的 , 真的应该在添加.catch()
每个承诺,对于您可以提醒任何失败的原因很简单。
将多个Promises作为一组运行的正确方法是将Promises存储在传递给Promise.all()
的数组中。
Promise.all()
将等到您的所有Promise.all()
都已解决或拒绝后,再将控制权返回给您的函数。
使用Promise.all()
时的另一个Promise.all()
是,一旦您的所有Promises都解决了,它将返回所有结果的数组,然后返回。
有关更多信息,请参见ES6承诺:模式和反模式 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.