feat(fts): honor per-field searchable flag#58
Merged
Conversation
SqliteItemRepository::syncFts() now consults the FieldRepository for the per-category set of `searchable: true` field names and filters the `items_fts.body` write accordingly. FullTextSearch:: rebuild() does the same in a single pre-pass over the fields table plus per-item iteration. Migration 0005_searchable_defaults.sql preserves existing FTS coverage on upgrade by promoting all `text/longtext/editor/slug` field rows to searchable=1 (matches the 2.2.0 factory defaults). Verified against a copy of the live Scriptor schema: all 8 text-typed fields promote; password + fileupload stay at 0. Backward compatibility: SqliteItemRepository's third constructor arg (?FieldRepository) is optional. The 2.0/2.1 two-arg signature keeps working — falls back to "index everything" with a one-time E_USER_DEPRECATED notice on first FTS write. Body composition extracted to FtsBody::compose() so the per-save writer and the bulk rebuilder cannot drift on the format. The plan called for per-process category-fields caching with event- based invalidation; revisited and dropped: per-save fetch from local SQLite is sub-millisecond, and the no-cache path can't go stale in long-running CLI processes. New test file SearchableFlagTest covers: opt-out per save, structural name+label always indexed, update refreshes set, rebuild respects flag, per-category isolation, flip-then-rebuild contract, migration 0005 row-level effect, legacy constructor deprecation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SqliteItemRepository::syncFts() now consults the FieldRepository for the per-category set of
searchable: truefield names and filters theitems_fts.bodywrite accordingly. FullTextSearch:: rebuild() does the same in a single pre-pass over the fields table plus per-item iteration.Migration 0005_searchable_defaults.sql preserves existing FTS coverage on upgrade by promoting all
text/longtext/editor/slugfield rows to searchable=1 (matches the 2.2.0 factory defaults). Verified against a copy of the live Scriptor schema: all 8 text-typed fields promote; password + fileupload stay at 0.Backward compatibility: SqliteItemRepository's third constructor arg (?FieldRepository) is optional. The 2.0/2.1 two-arg signature keeps working — falls back to "index everything" with a one-time E_USER_DEPRECATED notice on first FTS write.
Body composition extracted to FtsBody::compose() so the per-save writer and the bulk rebuilder cannot drift on the format. The plan called for per-process category-fields caching with event- based invalidation; revisited and dropped: per-save fetch from local SQLite is sub-millisecond, and the no-cache path can't go stale in long-running CLI processes.
New test file SearchableFlagTest covers: opt-out per save, structural name+label always indexed, update refreshes set, rebuild respects flag, per-category isolation, flip-then-rebuild contract, migration 0005 row-level effect, legacy constructor deprecation.