Reputation: 2134
We need to keep our Firebase
data in sync with other databases
for full-text search
(in ElasticSearch
) and other kinds of queries that Firebase
doesn't easily support.
This needs to be as close to real-time as possible, we can't just export a nightly dump of the Firebase JSON
or anything like that, aside from the fact that this will get rather large.
My initial thought was to run a Node.js
client which listens to child_changed
, child_added
, child_removed
etc... events of all the main lists, but this could get a bit unweildy and would it be a reliable way of syncing if the client re-connects after a period of time?
My next thought was to maintain a list of "items changed" events and write to that every time an item is created/updated, similar to the Firebase work queue example. The queue could contain the full path to the data which has changed and the worker just consumes that and updates the local database accordingly.
The problem here is every bit of code which makes updates has to remember to write to this queue otherwise the two systems will get out of sync. Some proxy code shouldn't be too hard to write though.
Has anyone else done anything similar with any success?
Upvotes: 14
Views: 11853
Reputation: 217324
Another option is to use the logstash-input-firebase Logstash plugin in order to listen to changes in your Firebase real-time database(s) and forward the data in real-time to Elasticsearch using an elasticsearch
output.
Upvotes: 1
Reputation: 40582
For search queries, you can integrate directly with ElasticSearch; there is no need to sync with a secondary database. Firebase has a blog post about integrating and a lib, Flashlight, to make this quick and painless.
Upvotes: 5