feat(repository): enhance document indexing with isEnabled and isRecommended fields

- Added `IsEnabled` and `IsRecommended` fields to the document indexing process in both ElasticFaiss and Elasticsearch repositories, improving the flexibility and functionality of document retrieval.
- Updated the data extraction process to include these new fields, ensuring they are correctly populated from the source data.
- Adjusted the indexing logic in the knowledge service to reflect these changes, maintaining consistency across the application.
This commit is contained in:
wizardchen
2026-03-02 15:03:54 +08:00
committed by lyingbug
parent b1fa96c175
commit 7b8a78aa2a
3 changed files with 23 additions and 0 deletions
@@ -1063,6 +1063,21 @@ func (e *elasticsearchRepository) processSingleHit(ctx context.Context,
sourceType = int(st)
}
// Extract is_enabled (default true for backward compatibility)
isEnabled := true
if v, ok := sourceObj["is_enabled"].(bool); ok {
isEnabled = v
}
// Extract is_recommended
isRecommended := false
if v, ok := sourceObj["is_recommended"].(bool); ok {
isRecommended = v
}
// Extract tag_id
tagID, _ := sourceObj["tag_id"].(string)
// Handle SourceID transformation for generated questions
// Generated questions have SourceID format: {chunkID}-{questionID}
// Regular chunks have SourceID == ChunkID
@@ -1100,6 +1115,9 @@ func (e *elasticsearchRepository) processSingleHit(ctx context.Context,
KnowledgeBaseID: targetKnowledgeBaseID,
Content: content,
SourceType: typesLocal.SourceType(sourceType),
IsEnabled: isEnabled,
IsRecommended: isRecommended,
TagID: tagID,
}
return indexInfo, embedding, nil