refactor: update document index removal methods for consistency and clarity
This commit is contained in:
@@ -119,15 +119,11 @@ func (s *index) IndexFAQByID(ctx context.Context, faqID int64) error {
|
||||
}
|
||||
|
||||
func (s *index) RemoveDocumentIndex(ctx context.Context, documentID int64) error {
|
||||
chunks := repositories.KnowledgeChunkRepository.Find(sqls.DB(), sqls.NewCnd().Eq("document_id", documentID))
|
||||
return s.removeDocumentIndexByChunks(ctx, documentID, chunks)
|
||||
chunks := repositories.KnowledgeChunkRepository.FindByDocumentID(sqls.DB(), documentID)
|
||||
return s.RemoveDocumentIndexByChunks(ctx, documentID, chunks)
|
||||
}
|
||||
|
||||
func (s *index) RemoveDocumentIndexByChunkModels(ctx context.Context, documentID int64, chunks []models.KnowledgeChunk) error {
|
||||
return s.removeDocumentIndexByChunks(ctx, documentID, chunks)
|
||||
}
|
||||
|
||||
func (s *index) removeDocumentIndexByChunks(ctx context.Context, documentID int64, chunks []models.KnowledgeChunk) error {
|
||||
func (s *index) RemoveDocumentIndexByChunks(ctx context.Context, documentID int64, chunks []models.KnowledgeChunk) error {
|
||||
if len(chunks) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ func (s *knowledgeDocumentService) DeleteKnowledgeDocument(id int64) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return rag.Index.RemoveDocumentIndexByChunkModels(context.Background(), id, chunks)
|
||||
return rag.Index.RemoveDocumentIndexByChunks(context.Background(), id, chunks)
|
||||
}
|
||||
|
||||
func (s *knowledgeDocumentService) buildKnowledgeDocumentModel(req request.CreateKnowledgeDocumentRequest) (*models.KnowledgeDocument, error) {
|
||||
|
||||
Reference in New Issue
Block a user