Skip to content

Commit 39572c7

Browse files
optimize(knowledge): Optimize the index logic of the knowledge base (coze-dev#841)
1 parent 0544a0c commit 39572c7

File tree

3 files changed

+442
-153
lines changed

3 files changed

+442
-153
lines changed

backend/domain/knowledge/internal/dal/dao/knowledge_document_slice.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"golang.org/x/sync/errgroup"
2727
"gorm.io/gorm"
28+
"gorm.io/gorm/clause"
2829

2930
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
3031
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
@@ -52,7 +53,7 @@ func (dao *KnowledgeDocumentSliceDAO) Update(ctx context.Context, slice *model.K
5253
}
5354

5455
func (dao *KnowledgeDocumentSliceDAO) BatchCreate(ctx context.Context, slices []*model.KnowledgeDocumentSlice) error {
55-
return dao.Query.KnowledgeDocumentSlice.WithContext(ctx).CreateInBatches(slices, 100)
56+
return dao.Query.KnowledgeDocumentSlice.WithContext(ctx).Clauses(clause.OnConflict{UpdateAll: true}).CreateInBatches(slices, 100)
5657
}
5758

5859
func (dao *KnowledgeDocumentSliceDAO) BatchSetStatus(ctx context.Context, ids []int64, status int32, reason string) error {

0 commit comments

Comments
 (0)