Skip to content

Commit 8aac14a

Browse files
committed
feat(data): FTS5 entity search engine
Adds a SQLite FTS5 virtual table `entities_fts` indexing seven entity types (projects, vendors, appliances, incidents, quotes, maintenance items, service logs) and the Go engine to populate and query it. - `entities_fts` virtual table with porter + unicode61 tokenization for stem-folded cross-language matching. - `RebuildFTSIndex` rebuilds the index from scratch from the live entity tables; safe to call repeatedly. - `populateEntitiesFTS` skips soft-deleted rows (including soft-deleted parents when JOINing) so the index never surfaces deleted data. - `SearchEntities` runs a MATCH query, returns BM25-ranked results with a stable `entity_id` tiebreaker, capped at 20 rows. - `EntitySummary` fetches a tri-state result (found / stale / missing) so callers can revalidate cached search hits before using them. - `truncateField` clips indexed content by rune count to keep the FTS shadow table bounded without splitting UTF-8 sequences. Test coverage: creation, rebuild, soft-delete exclusion (own rows and parents), cross-entity search, stemming, graceful degradation on corrupted schema, stale revalidation, Unicode truncation, tiebreaker determinism. This is the index and query layer only. Context-formatting helpers and caller wiring land in follow-up PRs. Refs #707.
1 parent 4291d12 commit 8aac14a

2 files changed

Lines changed: 883 additions & 4 deletions

File tree

0 commit comments

Comments
 (0)