/**
 * FTS5 Index Service
 *
 * Manages a SQLite FTS5 full-text search index for the Wiki-First
 * Knowledge System. Provides upsert, remove, search, and rebuild
 * operations over a `knowledge_fts` virtual table using Porter stemming
 * and Unicode61 tokenization.
 *
 * The database file is stored at `<knowledgePath>/index.fts5.db`.
 *
 * @module services/knowledge/fts5-index.service
 */
/**
 * A single result from an FTS5 search query.
 */
export interface FtsSearchResult {
    /** Document identifier */
    id: string;
    /** Document title */
    title: string;
    /** Space-separated tags */
    tags: string;
    /** Document body content */
    content: string;
    /** Document category */
    category: string;
    /** BM25 relevance rank (lower/more negative = more relevant in FTS5) */
    rank: number;
}
/**
 * Input document shape for upserting into the FTS5 index.
 */
export interface FtsDocument {
    /** Unique document identifier */
    id: string;
    /** Document title */
    title: string;
    /** Space-separated or comma-separated tags */
    tags: string;
    /** Document body content */
    content: string;
    /** Document category */
    category: string;
}
/**
 * Fts5IndexService manages a SQLite FTS5 full-text search database.
 *
 * It lazily initializes the database and FTS5 virtual table on first use,
 * and provides methods to upsert, remove, search, and rebuild the index.
 *
 * @example
 * ```typescript
 * const fts5 = new Fts5IndexService('/path/to/knowledge');
 * fts5.upsertDocument({ id: 'doc-1', title: 'Setup', tags: 'devops', content: '...', category: 'SOPs' });
 * const results = fts5.search('setup devops');
 * ```
 */
export declare class Fts5IndexService {
    private db;
    private readonly dbPath;
    private readonly logger;
    /**
     * Create an Fts5IndexService.
     *
     * @param knowledgePath - Directory where the FTS5 database will be stored
     */
    constructor(knowledgePath: string);
    /**
     * Get or lazily initialize the SQLite database connection.
     * Creates the parent directory and FTS5 virtual table if they do not exist.
     *
     * @returns The better-sqlite3 Database instance
     */
    private getDb;
    /**
     * Create the FTS5 virtual table if it does not already exist.
     * Uses Porter stemming and Unicode61 tokenization for broad language support.
     */
    private initSchema;
    /**
     * Upsert a document into the FTS5 index.
     * Removes any existing row with the same ID before inserting.
     *
     * @param doc - The document to upsert
     */
    upsertDocument(doc: FtsDocument): void;
    /**
     * Remove a document from the FTS5 index by its ID.
     *
     * @param id - The document identifier to remove
     */
    removeDocument(id: string): void;
    /**
     * Search the FTS5 index using a MATCH query with BM25 ranking.
     *
     * @param query - The search query string (FTS5 MATCH syntax)
     * @param options - Optional search parameters
     * @param options.category - Filter results by category
     * @param options.limit - Maximum number of results (default 10)
     * @returns Array of matching documents sorted by relevance
     */
    search(query: string, options?: {
        category?: string;
        limit?: number;
    }): FtsSearchResult[];
    /**
     * Rebuild the entire FTS5 index from scratch.
     * Drops all existing rows and reinserts the provided documents in a single transaction.
     *
     * @param documents - The complete set of documents to index
     */
    rebuildIndex(documents: FtsDocument[]): void;
    /**
     * Close the database connection and release resources.
     */
    close(): void;
}
//# sourceMappingURL=fts5-index.service.d.ts.map