Skip to content

Commit b72701a

Browse files
feat: Add search command with dual query formats (infix + MongoDB JSON) (#1098)
## Summary This PR implements the complete search feature for Kernel Memory, enabling users to query indexed content across multiple nodes and indexes with advanced filtering and relevance scoring. **Key Features:** - ✅ Dual query formats: SQL-like infix notation and MongoDB JSON - ✅ Multi-node parallel search with configurable weights - ✅ Multi-index search with diminishing returns reranking - ✅ Field-specific search with boolean operators (AND, OR, NOT) - ✅ Relevance scoring (0.0-1.0) with weighted reranking - ✅ Highlighting and snippet generation - ✅ Query validation and security limits - ✅ Comprehensive configuration and examples **Components Added:** - Core search service with node orchestration - Dual query parsers (Infix + MongoDB JSON) - SQLite FTS5 integration with stemming - Weighted diminishing returns reranking algorithm - CLI search command with 13 configuration flags - Consumer-friendly documentation (CONFIGURATION.md) - Interactive examples command (`km examples`) **Architecture:** - Transport-agnostic search service (ready for Web/RPC) - Parallel node searching with timeout handling - Memory-safe result limiting with recency bias - Comprehensive error handling and validation ## Test Coverage - 429 unit tests for reranking algorithm (all 5 examples from requirements) - 324+ tests for MongoDB JSON parser - 345+ tests for Infix parser - 206 equivalence tests (both parsers return identical AST) - 459 tests for LINQ query builder - Integration tests for search service - All search scenarios from requirements covered ## Documentation - **CONFIGURATION.md** (768 lines) - Complete consumer guide - Covers nodes, search settings, FTS indexes - 4 practical configuration examples - Impact warnings for configuration changes - Focused on implemented features only - **Examples Command** (`km examples`) - Interactive help - Practical examples for students, parents, professionals - All CLI commands covered (put, search, list, get, delete, nodes, config) - Power user tips for advanced scenarios ## Test Plan - [x] Simple keyword search: `km search "doctor appointment"` - [x] Field-specific search: `km search "title:lecture AND tags:exam"` - [x] Boolean logic: `km search "content:insurance AND (tags:health OR tags:auto)"` - [x] MongoDB JSON: `km search '{"content": "test", "tags": "important"}'` - [x] Multi-node search with weights - [x] Highlighting and snippets - [x] Pagination (limit/offset) - [x] Quality filtering (min-relevance) - [x] Query validation - [x] Configuration loading and validation - [x] Examples command display - [x] All builds pass with zero warnings ## Breaking Changes None - This is a new feature addition. ## Implementation Notes **Follows Requirements:** - All 5 score calculation examples verified with tests - Security limits implemented (query depth, operator count, field value length, parse timeout) - NoSQL-like semantics for flexible metadata **Success Criteria Met:** 1. ✅ Users can search with simple queries 2. ✅ Boolean logic works 3. ✅ Both infix and JSON formats supported 4. ✅ Multi-index search with reranking 5. ✅ Relevance scores 0.0-1.0 6. ✅ All tests passing 7. ✅ Zero-tolerance build passes (0 warnings, 0 errors) 8. ✅ Documentation complete --------- Co-authored-by: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
1 parent c376e9a commit b72701a

File tree

107 files changed

+9969
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+9969
-130
lines changed

AGENTS.md renamed to CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
- [ ] `format.sh` runs successfully without warnings or errors
1313
- [ ] `coverage.sh` runs successfully without warnings or errors
1414
- [ ] there are zero skipped tests
15+
- [ ] `KNOWN-ISSUES.md` is up to date
16+
- [ ] if a PR exists, the PR title, description and content are up to date
1517

1618
# C# Code Style
1719

0 commit comments

Comments
 (0)