feat(memory): migrate recall search from LIKE to SQLite FTS5#436
Merged
Conversation
…t search Replace LIKE '%term%' substring queries with FTS5 MATCH for all memory recall paths. This improves search precision (word-boundary matching instead of substring), adds BM25 relevance scoring, and provides index-backed queries that scale with document count. Changes: - Add memory_documents_fts and memory_records_fts virtual tables with Porter stemmer tokenization, rebuilt on each startup - Rewrite SearchByPlanInternalAsync, SearchAutoRecallDocumentsAsync, SearchMemoriesAsync, and FindCandidatesByContentAsync to use CTE-based FTS5 MATCH with bm25() ranking and policy-filter JOINs - Add FTS insert-on-write to all mutation paths (UpsertDocumentAsync, UpdateDocumentTextAsync, SupersedeRecordAsync, both batch methods) - Remove dead TokenizeQuery method and private StopWords set (shared TextTokenizer remains for query pre-processing) Closes #412
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.
Summary
LIKE '%term%'substring queries with FTS5MATCHacross all 4 memory recall search paths (SearchByPlanInternalAsync,SearchAutoRecallDocumentsAsync,SearchMemoriesAsync,FindCandidatesByContentAsync)memory_documents_ftsandmemory_records_ftsvirtual tables with Porter stemmer tokenization (porter unicode61 remove_diacritics 2)DeterministicCandidateSelector+RecallRank) unchangedTokenizeQuerymethod and privateStopWordsfield removed; sharedTextTokenizerremains for query pre-processingCloses #412
Test plan
find_memoriesreturns FTS-quality results