A sample Rails application can be found on GitHub https://github.com/searchly/searchly-rails-sample.

Ruby on Rails applications will need to add the following entry into their Gemfile.

gem 'elasticsearch-model'
gem 'elasticsearch-rails'
  

Update application dependencies with bundler. sh $ bundle install Configure Rails Elasticsearch in configure/application.rb or configure/environment/production.rb

elasticsearch::model.client = elasticsearch::client.new host: env['searchbox_url']
  

First add required mixin to your model;

class document < activerecord::base
    include elasticsearch::model
  end
  

From Rails console, create documents index for model Document.

document.__elasticsearch__.create_index! force: true
  

Make your model searchable:

class document < activerecord::base
    include elasticsearch::model
    include elasticsearch::model::callbacks
  end
  

When you now save a record:

document.create name: "cost",
                  text: "cost is claimed to be reduced and in a public cloud delivery model capital expenditure is converted."
  

The included callbacks automatically add the document to a documents index, making the record searchable:

@documents = document.search('cost').records
  

Elasticsearch Ruby/Rails has very detailed documentation at official Elasticsearch page.