If you have a ton of data to index, Flashlight will ask the ES to index each object on the fly without restricting access to resources. You must control / restrict access to this resource of the resource using Semaphore.
Install lib semaphore
npm i --save semaphore
Edit the PathMonitor.js file and restrict access to the ES resource to 1
PathMonitor.prototype = { _init: function () { this.sem = require('semaphore')(1); this.addMonitor = this.ref.on('child_added', this._process.bind(this, this._childAdded)); this.changeMonitor = this.ref.on('child_changed', this._process.bind(this, this._childChanged)); this.removeMonitor = this.ref.on('child_removed', this._process.bind(this, this._childRemoved)); }, ... _index: function (key, data, callback) { var that = this; that.sem.take(function () { that.esc.index({ index: that.index, type : that.type, id : key, body : data }, function (error, response) { that.sem.leave(); if (callback) { callback(error, response); } }.bind(that)); }); }, ... }
This may not be necessary with a paid plan.
source share