Skip to main content
Related: Quickstart, Configuration, CLI

Install

Add the gem to your host app:
gem "search-engine-for-typesense"
Create an initializer config/initializers/search_engine.rb:
SearchEngine.configure do |c|
  c.host = ENV.fetch("TYPESENSE_HOST", "localhost")
  c.port = ENV.fetch("TYPESENSE_PORT", 8108).to_i
  c.protocol = ENV.fetch("TYPESENSE_PROTOCOL", "http")
  c.api_key = ENV.fetch("TYPESENSE_API_KEY")
  # ...
end
It is recommended to add:
Rails.application.config.to_prepare do
  Dir.glob(Rails.root.join('app', 'search_engine', '**', '*.rb')).sort.each do |file_path|
    load file_path
  end
end
…in the initializer if you want to store your Typesense collections models in a non‑autoloaded directory. This snippet ensures that Typesense collection models load after the Rails application is ready (models are available). See Configuration for available knobs and ENV fallbacks.

Requirements

  • Ruby >= 3.1, Rails >= 6.1
  • Dependency: typesense >= 4.1.0 (pulled automatically, but may conflict with base64 gem — requires v0.2.0)
  • A running Typesense server reachable at host:port over protocol with a valid API key

Environment variables

  • TYPESENSE_HOST (e.g., localhost)
  • TYPESENSE_PORT (e.g., 8108)
  • TYPESENSE_PROTOCOL (http or https)
  • TYPESENSE_API_KEY (never commit to source control)

Post‑install checklist

  1. Bundle and boot your app.
  2. Verify configuration without leaking secrets:
    ruby script/dev/check_config.rb
    
  3. Run a smoke search against your Typesense server:
    ruby script/dev/smoke_client.rb
    
Next: tune defaults in Configuration and explore the Client.