Repository navigation
Description
Summary
An entity that has no search_index (FTS) row can never get a vector, no reindex variant short of
an explicit search pass repairs it, nothing reports it, and the only migration that promises a
backfill does nothing. On a long-lived local install (SQLite, upgraded through the 2025 migrations)
this left ~2.5% of all entities (110 of 4 453, across more than a dozen projects) unsearchable in every mode,
while bm project info reported full coverage. Verified against v0.23.2 and re-checked in the
v0.24.1 source; line references below are v0.24.1.
The four parts
bm reindex --full --embeddingsruns no search pass. The flags default to both only when
neither is given (cli/commands/db.py:291-294), and the docstring itself says
--full --embeddings # Full re-embed only. Vectors are built from FTS rows
(repository/semantic_vector_sync.py,fetch_prepare_window_source_rowsreads
FROM search_index), so an entity without one is skipped. The command still reports success
(in one case "7 entities embedded, 0 errors" with 0 chunks written). A user reading "full"
reasonably expects a rebuild that repairs this.- The backfill migration is empty.
i2c3d4e5f6g7_auto_backfill_semantic_embeddingssays
db.run_migrations()detects the revision transition and runssync_entity_vectors(); there is
no such hook inrun_migrations(db.py:540). Installs that enabled semantic search before this
revision keep their pre-existing notes unembedded until the files change. - FTS rows dropped by a migration never come back.
5fe1ab1ccebeandcc7172b46608drop and
recreatesearch_indexempty. The scan classifies files by checksum only
(indexing/change_planning.py:126-138), so an unchanged file is never re-indexed and its FTS row
(and therefore its vector) never returns. Symptom:entity.size IS NULLon those rows (the
column arrived later and is only written on re-index). project infocannot see the gap. It counts indexed entities as
COUNT(DISTINCT entity_id) FROM search_index(services/project_service.py:1321-1329) and
reports missing embeddings as FTS minus vectors, so an entity with neither is not counted
anywhere. Coverage should be measured againstentity(and arguably the files on disk).
Reproduction (part 1 + 4)
-- after deleting one entity's FTS rows, or on an install that went through the migrations above
SELECT COUNT(*) FROM entity e
WHERE NOT EXISTS (SELECT 1 FROM search_index s WHERE s.entity_id = e.id); -- > 0bm reindex -p <project> --full --embeddings → exit 0, the count above is unchanged.
bm project info <project> → reports no missing embeddings for those entities.
bm reindex -p <project> --full --search followed by embedding → the count goes to 0.
Suggested fixes
--full(with or without--embeddings) should include the search pass, or the embedding phase
should index entities that have no FTS row instead of skipping them silently.- Implement the promised backfill in
run_migrations, or remove the claim from the migration. - After a migration that drops
search_index, force a full search pass on next start (or treat
"entity without FTS row" as modified in change planning). - Measure coverage in
project infofromentity.
Workaround we use
bm reindex -p <project> --full --search, then embed the affected entities through
SearchService.sync_entity_vectors_batch (the per-entity path note writes use). We avoid
bm reindex --embeddings on large projects because of the reconcile cost fixed in #1581.
Activity
phernandez commentedon Oct 29, 2026
Fixed in #1954: index passes rebuild search rows for entities that have none,
bm reindex --embeddingsrestores them before embedding (and reports unreadable files as errors), andproject infocounts entities missing from the search index against the entity table. Thanks @SWSAmor for the detailed report.