I am new to rails and as well to elastic search. I have seen other resources to configure using Tire, Searchkick and some others, but I want to use Elasticsearch
gem. I have running rails application and running Elasticsearch server on my system but I do not how to configure them to communicate with each other.
Currently, I am facing a lot of troubles to do the same. Any help would be highly appreciated.
For a very basic quick start of the elastic's github gem for model indexing you could do the following in development environment with elasticsearch running on localhost:9200
in Gemfile:
then run on terminal:
in app/models/service.rb include right after class declaration:
you can now play with it on console with existing data (results are just an example):
For more information and details you can take a look at the project's github page
Better use elasticsearch-rails
in Gemfile:
To import the records from your Article model, run:
To limit the imported records to a certain ActiveRecord scope, pass it to the task:
Run this command to display usage instructions:
If you want to use for model
elasticsearch-model, which contains search integration for Ruby/Rails models such as ActiveRecord::Base and Mongoid,