/** * Inverted Index for fast collection search * * Provides O(k) search performance where k = number of matching entries * compared to O(n) linear search through all entries. * * Architecture: * - Token -> Set mapping for fast lookups * - Separate indexes for different fields (name, description, tags, etc.) * - Efficient tokenization with stop word filtering * - Case-insensitive with normalization */ import { IndexEntry } from '../types/collection.js'; /** * Statistics about the inverted index */ export interface InvertedIndexStats { totalTokens: number; totalEntries: number; avgTokensPerEntry: number; estimatedMemoryKB: number; lastBuilt: Date; buildTimeMs: number; } /** * Inverted index for fast collection search */ export declare class InvertedIndex { private index; private entries; private pathToId; private stats; /** * Build inverted index from entries */ build(entries: IndexEntry[]): void; /** * Index a single field for an entry */ private indexField; /** * Tokenize a string into searchable tokens * * Uses the same normalization as searchUtils for consistency */ private tokenize; /** * Check if a token is a common stop word * * Stop words are filtered to reduce index size and improve relevance */ private isStopWord; /** * Search the index for matching entries * * Returns entry IDs matching the query with relevance scores */ search(query: string): Array<{ entryId: number; score: number; }>; /** * Calculate relevance score based on which fields matched * * Name matches are most relevant, followed by tags, description, path */ private calculateFieldScore; /** * Get entry by ID */ getEntry(entryId: number): IndexEntry | undefined; /** * Get all entries (for filtering/sorting after search) */ getAllEntries(): IndexEntry[]; /** * Get index statistics */ getStats(): InvertedIndexStats; /** * Update statistics after index build */ private updateStats; /** * Estimate memory usage of the index */ private estimateMemoryUsage; /** * Check if index is empty */ isEmpty(): boolean; /** * Get number of indexed entries */ size(): number; } //# sourceMappingURL=InvertedIndex.d.ts.map