fix(core): Delete corresponding Milvus data when using with TuGraph #2858
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.
Description
Related to issue #2851
The database environment is Milvus + TuGraph + MySQL
The main problem is that when we delete a document in KnowledgeGraph Space, we only delete the TuGraph data, and the corresponding data remains in the Milvus _CHUNK_HISTORY collection, dragging down the database performance. This update only focuses on deleting the matching data in the Milvus environment when the user press the delete on the WebUI, while the change in chroma environment is expected in the future update.
This update contains two parts:
delete_by_file_id
function when user deletes the document in knowledge space.For part 1, the doc id is added as a new optional parameter and passed all the way down to the graph extractor. Then it will be loaded into the metadata.
For part 2, when we detect the user is using Milvus as the vector store environment, the
delete_document
method will also call thedelete_by_file_id
, deleting the Milvus data with the matching metadata.How Has This Been Tested?
Several documents have been uploaded and deleted with no error found.
Snapshots:
This is how matching doc_id is stored in the Milvus collection

When user deletes a document in knowledge space...

the corresponding data is also deleted in the collection!

Checklist: