rx-elasticsearch
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

Rx-elasticsearch Build Status npm version

RxJS Observables for the Elasticsearch javascript client

Install with npm npm install rx-elasticsearch --save

Wrap existing Elasticsearch client

import RxClient from 'rx-elasticsearch';
import * as elasticsearch from 'elasticsearch';
 
let client = new elasticsearch.Client({
    host: 'localhost:9200',
    log: 'info'
});
 
let rxClient = new RxClient(client);

Initialization without Elasticsearch client

import RxClient from 'rx-elasticsearch';
 
let rxClient = RxClient.create({
    host: 'localhost:9200',
    log: 'info'
});

Usage is the same as the Elasticsearch client, but returns observables.

let params = {
    index: 'yourIndex',
    body: {
        query: {
            match_all: {}
        }
    }
};
 
rxClient
    .search(params)
    .subscribe(
        (res) => console.log(res),
        (e) => console.error(e),
        () => console.log('done')
    );

With the scroll function you no longer need to call search first. This library takes care of that and clears the scroll automagicly when the scroll is finished.

let params = {
    index: 'yourIndex',
    scroll: '1m',
    size: 1000,
    body: {
        query: {
            match_all: {}
        }
    }
};
 
rxClient
    .scroll(params)
    .subscribe(
        (res) => console.log(res),
        (e) => console.error(e),
        () => console.log('done')
    );

For older javascript versions

var RxClient = require('rx-elasticsearch').default;

Package Sidebar

Install

npm i rx-elasticsearch

Weekly Downloads

1

Version

0.2.5

License

MIT

Last publish

Collaborators

  • reefstah