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 atconfig/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_cacheandcache_ttl_sare 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 toTypesense::Client’sconnection_timeout_seconds.open_timeout_ms: connect/open timeout (ms).retries:{ attempts: Integer, backoff: Float or Range<Float> }where backoff is in seconds.- When
backoffis a Range (e.g.,10.0..60.0), the client samples a single value at build time to introduce jitter between retries.
- When
Logger
Defaults toRails.logger when available; otherwise a $stdout logger at INFO level. You may supply any object responding to #info, #warn, and #error.
Test mode
Whentest_mode is true, the engine uses SearchEngine::Test::OfflineClient via
SearchEngine.client. This avoids network I/O and returns safe empty responses.
- Defaults to
truein Rails test (Rails.env.test?) or whenRACK_ENV=testis set - Can be overridden via
SEARCH_ENGINE_TEST_MODE=1orSEARCH_ENGINE_TEST_MODE=0 - Legacy
SEARCH_ENGINE_OFFLINEenv var is supported as an alias - If
SearchEngine.config.clientis set (e.g.,StubClient), it always takes precedence
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 theconfigure 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
CallingSearchEngine.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.