SwitchSearchable

Manages multiple search engines in your Rails app. Supported are - PGSearch, AlgoliaSearch and Elasticsearch.

Installation

Add this line to your application's Gemfile:

gem 'switch_searchable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install switch_searchable

Usage

Make sure you have setup services with Algolia, Elasticsearch. If you are using Postgresql nothing needs to be setup.

In your AR model:

class Lead < ActiveRecord::Base
  include SwitchSearchable::Searchable

  searchable_attributes(
    :company_name,
    :first_name,
    :last_name,
    :email,
    {phones: [:number]}
  )

  has_may :phones
end

To create an index, run:

Lead.reindex!

After that, you can now search:

Lead.search("Neil the man")

License

The gem is available as open source under the terms of the MIT License.