In BlogPost, Rails, Ruby

How to Setup Elasticsearch in your Rails App in Production

Step 1 – Install elasticsearch in your Rails Application in Production

If you haven’t setup elasticsearch in your Rails application in development, this article tells you how to do so in Linux

Step 2 – Create the search indices on your Heroku production application

At the command prompt, type the following:

If you’re running a staging environment, then you’d type staging instead of production. NAME_OF_MY_APP is the name of your Rails application running on Heroku.

Step 3 – Install the bonsai-elasticsearch-rails gem in your Gemfile and run bundle install

Now run bundle install at the command prompt.

Step 4 – Add the bonsai Heroku add-on to your application

At the command prompt type:

If everything has gone smoothly, you should see the BONSAI_URL envrionment variable when you type the following at the command prompt:

The BONSAI_URL environment variable:

When I did this, I actually ran into an issue with the BONSAI_URL not being initialized. I ended up contacting customer support and according to their customer support team, I had run into an edge case and they had to do something on their end to fix it. But they had the solution turned around within 24 hours of my initial contact.

Now, your rails application should be up and running with elasticsearch.

Recommended Posts