Flexible task search with prefix matching, slug search, and ranked results - #40
Merged
Merged
Conversation
…sults
Multi-strategy search replaces the single FTS5 query:
1. Exact task ID match
2. FTS5 prefix search ranked by BM25
3. Task ID substring match (LIKE)
4. Title substring fallback (LIKE)
Key changes:
- FTS query builder uses prefix syntax (word*) instead of exact ("word")
- Task ID now indexed as searchable FTS column (was UNINDEXED)
- Results ranked by BM25 relevance instead of updated_at
- Fix: task_update title rename no longer wipes FTS content index
- Fix: gateway PATCH route now preserves content+tags in FTS on save
- Migration v023 rebuilds tasks_fts with searchable task_id column
- 6 new tests for prefix, slug, dedup, and relevance ordering
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
Replaces the rigid FTS5 exact-word search with a multi-strategy approach that actually finds things:
distribnow finds "distribution documentation" (FTS5word*syntax instead of"word")2026-03-10-distributionfinds the task by ID substring. Task IDs are now indexed as searchable FTS columns (wereUNINDEXED)updated_at DESCAlso fixes two content-wipe bugs:
task_updatetitle rename calledupsert_task()withoutcontent=, nuking the FTS content indexreq.contentavailable but not passed throughChanges
nerve/db/tasks.py_build_fts_query(prefix), newsearch_tasks(multi-strategy), extracted_tokenize_query,_apply_status_filter,_apply_tag_filter,_row_matches_filtershelpersnerve/db/migrations/v023_tasks_fts_slug.pytasks_ftswithtask_idas searchable columnnerve/agent/tools.pynerve/gateway/routes/tasks.pytests/test_db.pytest_rebuild_ftsfor fallback behaviorTest plan