Skip to main content
Related: Installation, Client, CLI This engine centralizes all knobs under SearchEngine.config. These values drive the client and relation layers and are hydrated from ENV at boot by the engine initializer.

Field reference

ENV mapping

Only blank/unset fields are hydrated from ENV during engine boot; explicit initializer values win. SEARCH_ENGINE_TEST_MODE accepts 1/0, true/false, yes/no, on/off. When it is unset, SEARCH_ENGINE_OFFLINE is treated as a legacy alias.

Initializer

Place the following in your host app at config/initializers/search_engine.rb:
Note: ENV.fetch(“TYPESENSE_API_KEY”) will raise if not set. This is intentional for production/staging. In development you can omit an initializer and rely on defaults/ENV.

URL-level caching knobs

  • use_cache and cache_ttl_s are URL-level options consumed by the client. They should not be included in request bodies.

Timeouts & retries

  • timeout_ms: total request timeout (ms). Default is 60 minutes (3_600_000 ms) and maps to Typesense::Client’s connection_timeout_seconds.
  • open_timeout_ms: connect/open timeout (ms).
  • retries: { attempts: Integer, backoff: Float or Range<Float> } where backoff is in seconds.
    • When backoff is a Range (e.g., 10.0..60.0), the client samples a single value at build time to introduce jitter between retries.
Example overrides:

Logger

Defaults to Rails.logger when available; otherwise a $stdout logger at INFO level. You may supply any object responding to #info, #warn, and #error.

Test mode

When test_mode is true, the engine uses SearchEngine::Test::OfflineClient via SearchEngine.client. This avoids network I/O and returns safe empty responses.
  • Defaults to true in Rails test (Rails.env.test?) or when RACK_ENV=test is set
  • Can be overridden via SEARCH_ENGINE_TEST_MODE=1 or SEARCH_ENGINE_TEST_MODE=0
  • Legacy SEARCH_ENGINE_OFFLINE env var is supported as an alias
  • If SearchEngine.config.client is set (e.g., StubClient), it always takes precedence
Use SearchEngine.client to access the configured client instance. It respects SearchEngine.config.client when set, otherwise returns OfflineClient in test mode or a new Client instance.

Advanced Configuration

Beyond the top-level keys, several nested configurations control specific subsystems. These can be set in the configure block.

Indexer

Settings for bulk import and background processing.

Sources

Settings for data ingestion adapters.

Mapper

Settings for attribute mapping and coercions.

Partitioning

Settings for partitioned indexing and hooks.

Stale Deletes

Settings for stale document cleanup operations.

Observability & logging

See Observability for event payloads and redaction.

Grouping UX

Embedding

Settings for vector search auto-embedding. See Vector Search for the full guide.

Loader & console

Validation & warnings

Calling SearchEngine.configure { ... } validates obvious misconfigurations (bad protocol, negative timeouts, etc.). At boot, the engine logs a one-time warning if api_key or default_query_by are missing; secrets are not printed.