/** * Hybrid Search Implementation * * Combines vector (dense) search with BM25 (sparse) search for improved retrieval. * Supports multiple fusion methods: Reciprocal Rank Fusion (RRF) and Linear Combination. */ import type { BM25Result, HybridSearchConfig, HybridSearchResult, BM25Index, HybridSearchOptions } from "../../types/index.js"; /** * In-memory BM25 implementation for testing and development */ export declare class InMemoryBM25Index implements BM25Index { private documents; private avgDocLength; private k1; private b; search(query: string, topK?: number): Promise; addDocuments(documents: Array<{ id: string; text: string; metadata?: Record; }>): Promise; private tokenize; private countTermFrequency; private countDocumentsWithTerm; } /** * Reciprocal Rank Fusion * Combines rankings from multiple retrieval methods * * @param rankings - Array of ranking lists, each with id and rank * @param k - RRF constant (default: 60) * @returns Map of document IDs to fused scores */ export declare function reciprocalRankFusion(rankings: Array>, k?: number): Map; /** * Linear Combination of normalized scores * * @param vectorScores - Vector search scores * @param bm25Scores - BM25 search scores * @param alpha - Weight for vector scores (0-1), bm25 gets 1-alpha * @returns Map of document IDs to combined scores */ export declare function linearCombination(vectorScores: Map, bm25Scores: Map, alpha?: number): Map; /** * Create a hybrid search function * * @param options - Search options * @returns Hybrid search function */ export declare function createHybridSearch(options: HybridSearchOptions): (query: string, config?: HybridSearchConfig) => Promise;