> ## Documentation Index
> Fetch the complete documentation index at: https://nikita-shkoda.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Add the gem, create an initializer, verify requirements, and set ENV variables.

Related: <a href="/projects/search-engine-for-typesense/v30/quickstart">Quickstart</a>, <a href="/projects/search-engine-for-typesense/v30/configuration">Configuration</a>, <a href="/projects/search-engine-for-typesense/v30/cli">CLI</a>

## Install

Add the gem to your host app:

```ruby theme={null}
gem "search-engine-for-typesense"
```

Create an initializer `config/initializers/search_engine.rb`:

```ruby theme={null}
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:

```ruby theme={null}
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 <a href="/projects/search-engine-for-typesense/v30/configuration">Configuration</a> 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:
   ```bash theme={null}
   ruby script/dev/check_config.rb
   ```
3. Run a smoke search against your Typesense server:
   ```bash theme={null}
   ruby script/dev/smoke_client.rb
   ```

Next: tune defaults in <a href="/projects/search-engine-for-typesense/v30/configuration">Configuration</a> and explore the <a href="/projects/search-engine-for-typesense/v30/client">Client</a>.
