RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix: resolve template names in keyword graph search (#19640)
buua436c0e6bb21e1e8
diff --git a/internal/service/dataset_structure_graph.go b/internal/service/dataset_structure_graph.goindex 26fe8995a7..1b530ef526 100644--- a/internal/service/dataset_structure_graph.go+++ b/internal/service/dataset_structure_graph.go@@ -1197,6 +1197,32 @@ func (s *DatasetArtifactService) keywordSubgraph(ctx context.Context, tenantID,"knowledge_graph_kwd": []string{"entity"},}}+ if templateMeta == nil {+ templateMeta = map[string]map[string]interface{}{}+ }+ templateMetaLoaded := make(map[string]bool, len(templateMeta))+ for templateID := range templateMeta {+ templateMetaLoaded[templateID] = true+ }+ templateDAO := dao.NewCompilationTemplateDAO()+ resolveBucket := func(row map[string]interface{}) (map[string]interface{}, map[string]interface{}) {+ templateID := rowTemplateID(row)+ if templateID != "" && !templateMetaLoaded[templateID] {+ // Pipeline-produced rows can carry a template id even when the+ // document parser config does not contain the corresponding group.+ // Resolve it here as well as in the normal path so keyword searches+ // expose the user-visible template name instead of the opaque id.+ templateMetaLoaded[templateID] = true+ if template, err := templateDAO.GetTemplate(ctx, dao.DB, tenantID, templateID); err == nil && template != nil {+ templateMeta[templateID] = map[string]interface{}{+ "template_id": templateID,+ "template_name": template.Name,+ "kind": template.Kind,+ }+ }+ }+ return resolveGraphBucket(row, templateMeta, documentID)+ }topFields := append(append([]string{}, graphEntityFields...), "compilation_template_ids", "compile_kwd", "compilation_template_kind_kwd")textQuery := strings.TrimSpace(graphTextQueryRE.ReplaceAllString(keywords, " "))@@ -1322,7 +1348,7 @@ func (s *DatasetArtifactService) keywordSubgraph(ctx context.Context, tenantID,}scopeForTemplate := func(row map[string]interface{}) (map[string]interface{}, map[string]interface{}) {- return resolveGraphBucket(row, templateMeta, documentID)+ return resolveBucket(row)}bucketMeta, scope := scopeForTemplate(candidates[0].row)bucketID := graphStr(bucketMeta["template_id"])