Related: Schema, Indexer, CLI, Schema + Indexer E2E
Use this page when you need to reindex a collection with schema changes.
Fastest ways to reindex
CLI (safe blue/green)
rails 'search_engine:schema:apply[books]'
rails 'search_engine:schema:rollback[books]'
Ruby (auto fix drift)
SearchEngine::Book.index_collection(pre: :index)
SearchEngine::Bulk.index_collections(:books, :publishers)
reindex_collection! and Bulk.reindex_all! drop the
active physical collection. Use only when destructive reindexing is safe.
Destructive reindex (only if safe)
SearchEngine::Book.reindex_collection!
SearchEngine::Bulk.reindex_all!
Retention settings
Keep a limited number of old physical collections after swaps:
class SearchEngine::Book < SearchEngine::Base
schema_retention keep_last: 2
end
Next steps
- See Schema for
diff rules and retention behavior.
- Use Observability
to track schema apply and reindex events.