elasticsearch-doc-stream

1.0.0 • Public • Published

elasticsearch-doc-stream

A read stream of elasticsearch documents. Handy for reporting.

var docStream = require('elasticsearch-doc-stream');
 
var users = [];
 
var d = docStream({
  url: 'http://localhost:9200/test',
  search: {
    query: {
      match: {
        title: "elasticsearch"
      }
    }
  }
});
 
d.on('data', function (doc) {
  var user = doc._source.user;
  if (users.indexOf(user) === -1) {
    users.push(user);
  }
});
 
d.on('error', function (err) {
  console.error(err);
});
 
d.on('end', function () {
  console.log(users);
});

/elasticsearch-doc-stream/

    Package Sidebar

    Install

    npm i elasticsearch-doc-stream

    Weekly Downloads

    0

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • gsf