Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bimedia-fr/elastic-bulk-writable

expose elasticsearch BulkOp as a writable stream
https://github.com/bimedia-fr/elastic-bulk-writable

Last synced: 23 days ago
JSON representation

expose elasticsearch BulkOp as a writable stream

Awesome Lists containing this project

README

        

# elastic-bulk-writable
expose elasticsearch Bulk as a writable stream

## Install

> npm install --save elastic-bulk-writable

## Usage

Simple use case :

```js
var BulkWritable = require('elastic-bulk-writable');
var client; // get elastic client
var opts = {
client: client,
indexName: 'myindex',
indexType: 'mytype'
};
var writable = new BulkWritable(opts, function write(chunk, next) {
this.bulk.push({"index": {}});
this.bulk.push(chunk);
next();
});

readable.pipe(writable);
```

Index shortcut:

```js
var BulkWritable = require('elastic-bulk-writable');
var client; // get elastic client
var opts = {
client: client,
indexName: 'myindex',
indexType: 'mytype'
};
var writable = new BulkWritable(opts);
readable.pipe(writable);
```