A elasticsearch nodejs batching queue.
$ npm install elastic-queueTo use the ElasticQueue, you simply need to require it and
then initialize a new queue with parameters:
varElasticQueue=require('elastic-queue');Queue=newElasticQueue();varelasticDocument;elasticDocument={index: 'elastic-product',type: 'queue',id: 0,body: {metadata: {fileName: 'inputFile'}}};Queue.push(elasticDocument);The following options are availble to configure ElasticQueue:
elasticsearch:client:# http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/configuration.html#config-optionshost:"localhost:9200"log:"info"minSockets:1sniffInterval:60000sniffOnStart:truesuggestCompression:trueconcurency:1# number of active batchesbatchSize:500# batch sizecommitTimeout:1000# wait time before sending partial batchesrateLimit:2000# wait time between batches are added to the queuebatchType:"batch_single"# batch_single: convert singles into batchesEvent Listeners
- drain: queue is empty
- task: batch is added to queue
- batchComplete: batch is complete
Queue.on('task',function(batch){returnconsole.log("task",batch);});Queue.on('batchComplete',function(resp){returnconsole.log("batch complete",resp);});Queue.on('drain',function(){console.log("\n\nQueue is Empty\n\n");returnQueue.close();});