import type { Tool } from '../../../shared/models/tool.model.js'; /** * SearchScorer class provides relevance scoring functionality for search results. * It calculates weighted scores for tools based on how well their fields (name, description) * match against a given search query using different matching strategies. * * The scoring algorithm prioritizes matches in the following order: * 1. Exact name matches (highest priority) * 2. Name prefix matches (second highest priority) * 3. Partial matches in name or description (lower priority) * * Each field has configurable weights that determine its importance in the final score. * The name field typically has a higher weight than the description field to ensure * that tools with relevant names appear higher in search results. * * This class is used by the SearchCoreService to rank and sort search results * based on relevance to provide better user experience in tool discovery. */ export declare class SearchScorer { /** * Calculates the relevance score for a tool against a search query. * * The scoring logic ensures proper ranking by: * - Giving exact name matches the highest possible score (120 points) * - Ensuring name prefix matches have higher scores than any combination of * partial matches in other fields * - Combining scores from multiple fields while maintaining proper priorities * * @param tool - The Tool object to score against the query * @param query - The search query string to match against tool fields * @returns A numerical score representing the relevance of the tool to the query * Higher scores indicate better matches */ scoreTool(tool: Tool, query: string): number; /** * Calculates the score for a single text field against a search query. * * The scoring uses three levels of matching with decreasing priority: * 1. Exact match: Returns 10 * weight (highest score) * 2. Prefix match: Returns 5 * weight (medium score) * 3. Contains match: Returns 3 * weight (lowest score) * 4. No match: Returns 0 * * This method performs case-insensitive matching by converting both * the input text and query to lowercase before comparison. * * @param text - The text field to evaluate (e.g., tool name or description) * @param query - The lowercase search query to match against * @param weight - The importance weight for this field (higher = more important) * @returns A numerical score based on the match type multiplied by the field weight */ private scoreField; } //# sourceMappingURL=search-scorer.d.ts.map