Commands
- collection: either a fully-qualified class name (e.g.,
SearchEngine::Book) or a logical identifier (e.g.,book/books). - partition: opaque partition key. Numeric strings are parsed as integers; otherwise treated as strings.
Usage
- Show tasks:
rails -T | grep search_engine - Diff schema:
rails ‘search_engine:schema:diff[SearchEngine::Book]’ - Apply schema:
rails ‘search_engine:schema:apply[books]’ - Rollback schema:
rails ‘search_engine:schema:rollback[books]’ - Rebuild all partitions:
rails ‘search_engine:index:rebuild[SearchEngine::Book]’ - Rebuild a partition:
rails ‘search_engine:index:rebuild_partition[SearchEngine::Book,42]’ - Delete stale docs:
rails ‘search_engine:index:delete_stale[books,42]’ - Doctor diagnostics:
rails search_engine:doctor
Note:
rails -T always prints task names without quotes (e.g., rails search_engine:index:rebuild[collection]). When invoking tasks that use brackets, wrap the whole invocation in quotes to avoid shell globbing, e.g., rails ‘search_engine:index:rebuild[products]’.Environment flags
DRY_RUN=1: Forindex:rebuild, preview first batch only (no HTTP); forindex:delete_stale, show filter hash and estimation (if enabled) without deleting.DISPATCH=inline|active_job: Override dispatch mode for rebuild tasks (defaults from config).VERBOSE=1: Print additional details (e.g., schema diff JSON and dry-run sample line). Fordoctor, shows untruncated hints.FORMAT=json: Machine-readable output. Fordoctor, prints{ ok, summary, checks }.STRICT=1: Forindex:delete_stale, treat missing filter as violation.TIMEOUT=seconds: Fordoctor, override per-request timeout for health/API calls.HOST/PORT/PROTOCOL: Fordoctor, temporary overrides to test connectivity.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Rollback not possible |
| 3 | Strict safety violation |
| 10 | Schema drift detected (diff) |
Behavior summary
schema:diff: Compares compiled schema vs the active physical (via alias). Prints compact summary;VERBOSE=1dumps details. Exits10when drift exists.schema:apply: Creates a new physical, reindexes (all partitions), swaps alias, drops old physicals per retention. Prints a compact summary.schema:rollback: Swaps alias to previous retained physical. Exits2when none available.index:rebuild: IfpartitionsDSL exists, enumerates and dispatches per partition; otherwise a single inline run.DRY_RUN=1maps only the first batch and prints a preview. Does not perform alias swaps or retention cleanup; useschema:applyfor blue/green and retention.index:rebuild_partition: Rebuilds a single partition; respectsDISPATCHor config defaults.index:delete_stale: Compilesstalerules (declared insideindex) into an OR‑merged filter and deletes by filter. If no rules produce a filter: warns and exits0, or3withSTRICT=1.DRY_RUN=1prints preview without deleting.doctor: Validates config/ENV presence, connectivity (health), API key validity, alias resolution for registered collections, compiles a dry-run single search and a multi-search without I/O, reports logging mode, and OpenTelemetry status. Prints human-readable by default or JSON withFORMAT=json. Exits1on any failure.
Doctor flow
Backlinks: Observability → OpenTelemetry, Installation, Configuration See also: Configuration and Observability for logging and OTel.Safety notes
- Stale deletes never run with an empty filter. A short hash of the filter is printed for traceability.
- Partition keys are opaque. Numeric strings are converted to integers; other values remain strings.
See also
- Schema — compiler, diff, apply! and rollback
- Indexer — import flow, dry-run, partitioning, dispatcher
- Observability