/**
 * Query Expander for Legal/Medical Domain + Corpus-Driven Expansion
 *
 * Expands search queries with domain-specific synonyms and corpus cluster top terms.
 * When enabled, the query "injury" also searches for "wound", "trauma", etc.
 * With a database connection, also expands from cluster top_terms_json for
 * corpus-specific vocabulary.
 *
 * CRITICAL: NEVER use console.log() - stdout is reserved for JSON-RPC protocol.
 *
 * @module services/search/query-expander
 */
import type { DatabaseService } from '../storage/database/index.js';
/**
 * Sanitize a single term for safe inclusion in an FTS5 OR-joined query.
 *
 * 1. Strips all FTS5 metacharacters
 * 2. Returns empty string if the cleaned term is an FTS5 operator (AND/OR/NOT)
 *    to prevent accidental operator injection from corpus/table data
 *
 * @param term - Raw term from corpus clusters, table columns, or synonyms
 * @returns Sanitized term safe for FTS5, or empty string if term should be skipped
 */
export declare function sanitizeFTS5Term(term: string): string;
/**
 * Get matching table column names from provenance processing_params.
 * Searches for column headers that contain any of the query words.
 *
 * @param db - DatabaseService instance
 * @param queryWords - Lowercased query words to match against column names
 * @returns Array of matching column name terms
 */
export declare function getTableColumnExpansionTerms(db: DatabaseService, queryWords: string[]): string[];
/**
 * Query cluster top terms from the database for corpus-specific expansion.
 *
 * For each query word, checks if it appears in any cluster's top_terms_json
 * (clusters with coherence_score > 0.3). Returns other terms from matching
 * clusters as expansion candidates (max 3 per cluster match).
 *
 * @param db - DatabaseService instance
 * @param queryWords - Lowercased query words to match against cluster terms
 * @returns Map of query word -> corpus expansion terms
 */
export declare function getCorpusExpansionTerms(db: DatabaseService, queryWords: string[]): Record<string, string[]>;
/**
 * Get detailed expansion information for a query.
 * Shows which words were expanded and what synonyms were found.
 * When a database is provided, also includes corpus-driven expansion from cluster top terms.
 *
 * @param query - Original search query
 * @param db - Optional DatabaseService for corpus-driven expansion
 * @param isTableQuery - Whether the query targets table content
 * @returns Expansion details: original query, new expanded terms, synonym map, corpus terms
 */
export declare function getExpandedTerms(query: string, db?: DatabaseService, isTableQuery?: boolean): {
    original: string;
    expanded: string[];
    synonyms_found: Record<string, string[]>;
    corpus_terms?: Record<string, string[]>;
    table_column_terms?: string[];
};
/**
 * Expand query using static synonyms and optional corpus cluster terms.
 * When isTableQuery is true, also expands with matching table column names.
 *
 * @param query - Original search query
 * @param db - Optional DatabaseService for corpus-driven expansion
 * @param isTableQuery - Whether the query targets table content
 * @returns OR-joined expanded query string
 */
export declare function expandQuery(query: string, db?: DatabaseService, isTableQuery?: boolean): string;
//# sourceMappingURL=query-expander.d.ts.map