Conversation
Co-authored-by: streed <805140+streed@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR ensures data consistency by implementing comprehensive document deletion for the lil-rag vector search service when notes are removed. Previously, deleting notes only removed them from the local database, leaving orphaned documents in the vector index.
- Added new deletion methods to both the lil-rag client and search interface to remove indexed documents
- Enhanced delete commands to clean up both database and vector index entries
- Added unit tests to verify document ID consistency between indexing and deletion operations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/lilrag/client.go | Added DeleteDocument methods and corresponding request/response structs for API communication |
| internal/search/lilrag_search.go | Implemented DeleteNote methods that generate consistent document IDs and handle namespace management |
| internal/search/lilrag_search_test.go | Added unit tests to verify document ID format consistency between indexing and deletion |
| cmd/delete.go | Enhanced both single and bulk deletion commands to remove documents from lil-rag vector index |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| func getDocumentID(noteID int, projectID string) string { | ||
| // This mirrors the logic in IndexNoteWithNamespace and DeleteNoteWithNamespace | ||
| return fmt.Sprintf("notes-%s-%d", projectID, noteID) | ||
| } |
There was a problem hiding this comment.
This helper function duplicates the document ID generation logic from the production code. Consider extracting the actual document ID generation into a shared utility function to avoid code duplication and ensure consistency.
Problem
When deleting notes using the
ml-notes deletecommand, the system was only removing notes from the local database but not cleaning up the corresponding indexed documents in the lil-rag vector search service. This resulted in:Solution
This PR implements comprehensive document deletion for lil-rag integration:
New API Methods
lilrag.Client:DeleteDocument(id string)andDeleteDocumentWithNamespace(id, namespace string)methodsDeleteRequestandDeleteResponsestructs for proper API communicationsearch.LilRagSearch:DeleteNote(noteID int)andDeleteNoteWithNamespace(noteID int, namespace, projectID string)methodsnotes-{projectID}-{noteID}Updated Delete Commands
Both single note deletion and bulk deletion (
--all) now:Example Usage
Key Features
Testing
This change ensures the ml-notes system maintains data integrity across all storage layers, preventing the accumulation of orphaned search index entries.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.