This example illustrates basic search features of Searchly with Rails. Elasticsearch rails client is used for integration. Each crud operation is reflected to Searchly via model callbacks.
Please see development.rb and production.rb for Elasticsearch connection url settings.
elasticsearch_url = ENV['SEARCHBOX_URL'] || ENV['SEARCHLY_URL'] ||
JSON.parse(ENV['VCAP_SERVICES']['searchly'][0]['credentials']['uri']) || 'http://site:xyz-searchly.com'
Elasticsearch::Model.client = Elasticsearch::Client.new host: elasticsearch_urlrake db:migrate
rake db:seed
Recreate/Create index and import all data
bundle exec rake environment elasticsearch:import:model CLASS='Restaurant' FORCE=yStart rails console and execute below command to create index and mapping
Restaurant.__elasticsearch__.create_index! force: trueAfter index is created you can seed example data via;
rake db:seedwhich will insert sample restaurants to database as well as Elasticsearch.
You can also execute
Restaurant.importat rails console.