fix(search): resolve zero results bug and improve UX #20
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.
🐛 Problem
Search was indexing 566 documents but returning 0 results for all queries, making the semantic search feature completely non-functional.
Root Cause
LanceDB returns L2 distance (~1.0 for similar vectors), but our code incorrectly calculated:
All results scored 0 and were filtered out by the threshold.
✅ Solution
1. Fix Distance-to-Similarity Conversion
score = e^(-distance²)2. Fix CLI Metadata Access
metadata.file→metadata.path3. Add Comprehensive Tests
4. Update Documentation
🧪 Verification
Before:
$ dev search "coordinator" --threshold 0.7 ✖ Found 0 result(s)After:
$ dev search "coordinator" --threshold 0.3 1. CoordinatorLogger (42.6% match) 2. Coordinator - The Central Nervous System (42.4% match) 3. CoordinatorLogger.info (35.6% match) ✔ Found 3 result(s)Test Results:
📊 Impact
Search Quality Examples:
RepositoryIndexervector embeddingshow do agents communicateerror handlingScore Interpretation:
🔗 Commits (Atomic)
fix(search): Correct distance-to-similarity calculationtest(search): Add 11 comprehensive integration testschore: Update gitignore, remove tsx dependencydocs: Update READMEs with real examplesEach commit builds and tests independently.
🚀 Next Steps
explore similarcommand (searches filename as text, not content)Dogfooded on dev-agent itself: All examples are real searches on this repository! 🐕