Skip to content

Instantly share code, notes, and snippets.

@AndreiD
Created August 23, 2016 16:54
Show Gist options
  • Save AndreiD/651b1e8b30e1e98c2d7cbb2979575811 to your computer and use it in GitHub Desktop.
Save AndreiD/651b1e8b30e1e98c2d7cbb2979575811 to your computer and use it in GitHub Desktop.
firebase_to_elastic_search
1. install java
2. sudo apt-get install npm
3. Download latest ES https://www.elastic.co/downloads/elasticsearch
wget <PASTE_LINK>
4. sudo dpkg -i elasticsearch-<version>.deb
5. (optional) sudo update-rc.d elasticsearch defaults
Configure it
The Elasticsearch configuration files are in the /etc/elasticsearch
Example:
cluster.name: firebasesyncapp
node.name: node_fb_1
path.data: /home/elasticsearch
path.logs: /home/elasticsearch/logs
network.host: 0.0.0.0 (worry about security later ;)
http.port: 9200
6. $service elasticsearch start
7. Test if everythins is ok:
$service elasticsearch status (should show running)
from your browser http://serverip:9200 should show a json file with configurations.
8. Install Flashlight
$mkdir /tmp/flashlight
$cd /tmp/flashlight
git clone https://github.com/firebase/flashlight
$cd flashlight (where the package.json file is)
npm install
generate a new Firebase service account and configuring FB_SERVICEACCOUNT, https://firebase.google.com/docs/database/server/start
create a new file on the server names service_account.json and paste the content of the downloaded file
9. edit the config file: change the firebase url (FB_URL) to your database. and on the FB_ACCOUNT write "service_account.json"
10. $nodejs app.js
11. You have some data into your database right? Let's test the query
http://server_ip:9200/firebase/_search
in your browser:
http://server_ip:9200/_search?source={ "from" : 0, "size" : 100 , "query": { "match_all": {}} }
That's all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment