Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get elastic search to play with MongoDb and node.js?

I am fairly new to both mongodb and node.js but recently got everything to work well for me until I reached the point where I needed to add a full text search to my website. From my research I figured out that Elasticsearch would be a good fit, but I couldnt figure out exactly how to get it to work with node.js and mongodb. I am currently using Heroku and MongoLab to host my application. Here are my questions.

  1. How do I host Elasticsearch?

  2. How do I make all my mongo data available to elasticsearch do I use a river or do I manually inset and delete all data?

    I found something this river but I am not quite sure how to make this happen automatically and where to host it.

  3. How do I query Elasticsearch from node.js? Is there a package that allows for this?

Edit:

Question 2 is really what I am struggling with. I have also included question 1 and 3 to help people that are new to the topic and coming from google.

like image 650
Marwan Roushdy Avatar asked Feb 11 '13 11:02

Marwan Roushdy


1 Answers

1) either on your own server/VM/whatever.. or with a hosted service such as https://searchbox.io/

2) you can create a script to index your existing data and then index new data once its created, or use a river to index your current database.

3) ElasticSearch is a simple HTTP API, you can make your own requests using the 'http' module or simplify it with something like https://github.com/mikeal/request

you can also use a 3rd party library like https://github.com/phillro/node-elasticsearch-client

like image 59
Gal Ben-Haim Avatar answered Sep 27 '22 18:09

Gal Ben-Haim