rethinkdb-elasticsearch-stream
🔄 sync RethinkDB tables to Elasticsearch using changefeeds
A JavaScript-based replacement for the deprecated Elasticsearch RethinkDB River plugin. This can populate your Elasticsearch instance using data from a RethinkDB instance, keep it up to date using changefeeds, and allow you to modify the documents before they're copied.
✨ Features:
- Simple: specify connections and tables to copy as-is to Elasticsearch
- Flexible: accepts a transform function for each table to modify what's copied
- Tested
Usage
Simple example:
import rethinkdbElasticsearchStream from 'rethinkdb-elasticsearch-stream'
await rethinkdbElasticsearchStream({
backfill: true,
elasticsearch: { host: '127.0.0.1', port: 9200 },
rethinkdb: { host: '127.0.0.1', port: 28015 },
tables: [{ db: 'megacorp', table: 'users' }],
watch: true
});
Everything:
import rethinkdbElasticsearchStream from 'rethinkdb-elasticsearch-stream'
await rethinkdbElasticsearchStream({
backfill: true,
elasticsearch: {
host: '127.0.0.1',
port: 9200,
protocol: 'http'
},
rethinkdb: {
host: '127.0.0.1',
port: 28015,
protocol: 'http'
},
tables: [
{
db: 'megacorp',
deleteTransform: async ({db, document, oldDocument, table }) => {
if (await someImportantCheck()) {
return oldDocument;
}
return {
_delete
id: oldDocument.id,
}
},
esType: 'webUsers',
idKey: 'id',
table: 'users',
transform: async ({ db, document, oldDocument, table }) => {
await doSomethingImportant()
return document;
}
}
],
watch: true
});
Install
With Yarn or npm installed, run:
yarn add rethinkdb-elasticsearch-stream
npm install rethinkdb-elasticsearch-stream
See Also
rethinkdb-elasticsearch-stream was inspired by:
License
MIT