/**
 * Memory Search Index - High-performance indexed search for Memory elements
 *
 * Addresses issue #984: Implement search indexing for Memory element scalability
 *
 * Features:
 * - Tag index for O(1) tag-based queries
 * - Content index using inverted index pattern
 * - Temporal index for date range queries
 * - Privacy level index for filtered access
 * - Incremental index updates
 * - Optional persistence
 * - Configurable thresholds
 */
import { MemoryEntry } from './types.js';
import { PrivacyLevel } from './constants.js';
type MemoryEntryMap = Map<string, MemoryEntry> | {
    has: (key: string) => boolean;
    keys: () => Iterable<string>;
    values: () => Iterable<MemoryEntry>;
    get: (key: string) => MemoryEntry | undefined;
    size: number;
    [Symbol.iterator]: () => Iterator<[string, MemoryEntry]>;
};
export interface SearchIndexConfig {
    /**
     * Enable indexing when memory has more than this many entries
     * Default: 100
     */
    indexThreshold?: number;
    /**
     * Enable content index (more memory intensive)
     * Default: true
     */
    enableContentIndex?: boolean;
    /**
     * Maximum number of terms to index per entry
     * Default: 100
     */
    maxTermsPerEntry?: number;
    /**
     * Minimum term length to index
     * Default: 2
     */
    minTermLength?: number;
    /**
     * Enable index persistence to disk
     * Default: false
     */
    enablePersistence?: boolean;
    /**
     * Maximum memory usage in MB
     * Default: 100
     */
    maxMemoryMB?: number;
    /**
     * Enable LRU eviction when memory limit is reached
     * Default: true
     */
    enableLRUEviction?: boolean;
}
export interface SearchIndexStats {
    isIndexed: boolean;
    entryCount: number;
    tagCount: number;
    termCount: number;
    lastBuilt?: Date;
    buildTimeMs?: number;
    memoryUsageBytes?: number;
}
export interface SearchQuery {
    tags?: string[];
    content?: string;
    dateFrom?: Date;
    dateTo?: Date;
    privacyLevel?: PrivacyLevel;
    limit?: number;
    offset?: number;
}
export interface SearchResult {
    entry: MemoryEntry;
    score: number;
    matches: {
        tags?: string[];
        terms?: string[];
    };
}
/**
 * Main search index for Memory elements
 */
export declare class MemorySearchIndex {
    private readonly config;
    private tagIndex;
    private privacyIndex;
    private contentIndex;
    private temporalIndex;
    private entriesCache;
    private isBuilt;
    private isBuilding;
    private buildQueue;
    private stats;
    private readonly maxMemoryBytes;
    private memoryUsageBytes;
    constructor(config?: SearchIndexConfig);
    /**
     * Build or rebuild the index from entries
     * FIX: Added race condition protection with isBuilding flag and build queue
     */
    buildIndex(entries: MemoryEntryMap): Promise<void>;
    private _doBuildIndex;
    /**
     * Add a single entry to the index (incremental update)
     */
    addEntry(entry: MemoryEntry): void;
    /**
     * Remove an entry from the index
     */
    removeEntry(entryId: string): void;
    /**
     * Search the index with multiple criteria
     */
    search(query: SearchQuery, entries: MemoryEntryMap): SearchResult[];
    /**
     * Fallback linear search when index is not available
     */
    private linearSearch;
    /**
     * Internal helper to add entry to all indexes
     */
    private addToIndex;
    /**
     * Clear all indexes
     */
    clear(): void;
    /**
     * Get index statistics
     */
    getStats(): SearchIndexStats;
    /**
     * Check if index is built
     */
    get isIndexed(): boolean;
    /**
     * Calculate and update memory usage
     * FIX: Added memory monitoring for content index
     */
    private updateMemoryUsage;
    /**
     * Evict least recently used entries to free memory
     * FIX: Added LRU eviction for memory management
     */
    private evictLRUEntries;
    /**
     * Serialize index to JSON for persistence
     * FIX: Added index serialization for cold start optimization
     */
    serialize(): string;
    /**
     * Deserialize index from JSON
     * FIX: Added index deserialization for faster startup
     */
    deserialize(data: string, entries: Map<string, MemoryEntry>): void;
}
export {};
//# sourceMappingURL=MemorySearchIndex.d.ts.map