An example application for integrating Rails 5 API with Elasticsearch. Read a more in depth explaination on https://medium.freecodecamp.org/how-to-add-a-powerful-search-engine-to-your-rails-backend-57bced889032
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.zip
unzip elasticsearch-6.2.3.zip
git clone https://github.com/domangi/movies-search.git
cd movies-search; bundle install
rails db:migrate
Open config/elasticsearch.yml and change your elasticsearch binary path if needed.
To be sure that your setup is working run the test suite.
bundle exec rpsec
You can prepopulate your movies database from a large dataset published on Kaggle (https://www.kaggle.com/rounakbanik/the-movies-dataset):
First start your elasticsearch server so that the data can be indexed while it is created. You can start your elasticsearch server by running:
elasticsearch-6.2.3/bin/elasticsearch
Now run the seed script to import the dataset
rails db:seed
rails s
Url: GET /api/v1/movies
Params: q=[string] required
Example request: GET /api/v1/movies?q=Roman
Example response:
[
{
"_index":"movies",
"_type":"movie",
"_id":"95088",
"_score":11.549209,
"_source":
{
"id":95088,
"title":"Roma",
"overview":"A virtually plotless, gaudy, impressionistic portrait of Rome through the eyes of one of its most famous citizens.", "image_url":"https://image.tmdb.org/t/p/w300/rqK75R3tTz2iWU0AQ6tLz3KMOU1.jpg",
"vote_average":6.6,
"created_at":"2018-04-14T10:30:49.110Z",
"updated_at":"2018-04-14T10:30:49.110Z"
}
},
...
]