/** * global-retrieval.ts — 全局层聚合检索入口(RAG + 知识图谱) * * 把「RAG 关键词检索」和「知识图谱实体匹配」结合起来,提供全局层文档的 * 统一检索入口: * 1. 图谱匹配:用查询关键词在知识图谱中定位实体(title/semanticTags/businessRole) * 2. 邻居扩展:收集一阶关联实体,扩大上下文 * 3. RAG 检索:在全局索引中检索相关 chunk * 4. 图谱加分重排:与图谱实体相关的 chunk 获得加分 * * 复用 rag-engine.retrieveWithGraphContext(其 KGLiteGraph 与 KnowledgeGraph 结构兼容)。 * 检索失败时降级为纯 RAG 检索(retrieveRelevantChunks),保证可用。 * * v8.3.184+ */ import { type DocumentChunk } from './rag-engine'; export interface GlobalSearchOptions { /** 查询语句(需求关键词 / 实体名 / 模块名) */ query: string; /** 最多返回几块,默认 5 */ topK?: number; /** 按端过滤(如 ['backend','admin']) */ platforms?: string[]; /** 是否启用图谱加分,默认 true */ graphBoost?: boolean; /** RAG 索引文件名,默认 rag-index-global.json */ fileName?: string; } export interface GlobalSearchResult { query: string; chunks: DocumentChunk[]; /** 匹配到的图谱实体标题(供追溯) */ matchedEntities: string[]; graphBoosted: boolean; totalFound: number; } export declare function searchGlobalKnowledge(options: GlobalSearchOptions): Promise; //# sourceMappingURL=global-retrieval.d.ts.map