import * as plugins from './smartfuzzy.plugins.js'; /** * Type for the search result returned by ArticleSearch */ export type IArticleSearchResult = { /** The matched article */ item: plugins.tsclass.content.IArticle; /** The index of the article in the original array */ refIndex: number; /** The match score (lower is better) */ score?: number; /** Information about where matches were found in the article */ matches?: ReadonlyArray<{ indices: ReadonlyArray; key?: string; value?: string; refIndex?: number; }>; }; /** * Specialized search engine for articles with weighted field searching * * This class provides fuzzy searching against article content, with different weights * assigned to different parts of the article (title, tags, content) to provide * more relevant results. * * @example * ```typescript * const articles = [ * { * title: 'Getting Started with TypeScript', * content: 'TypeScript is a superset of JavaScript that adds static typing...', * tags: ['typescript', 'javascript', 'programming'], * author: 'John Doe', * timestamp: Date.now(), * featuredImageUrl: null, * url: 'https://example.com/typescript-intro' * } * ]; * * const articleSearch = new ArticleSearch(articles); * const results = await articleSearch.search('typescript'); * ``` */ export declare class ArticleSearch { /** * Collection of articles to search through */ articles: plugins.tsclass.content.IArticle[]; /** * Flag indicating whether the search index needs to be updated */ needsUpdate: boolean; /** * Promise manager for async operations */ private readyDeferred; /** * Fuse.js instance for searching */ private fuse; /** * Creates a new ArticleSearch instance * * @param articleArrayArg - Optional array of articles to initialize with */ constructor(articleArrayArg?: plugins.tsclass.content.IArticle[]); /** * Adds an article to the collection and marks the index for updating * * @param articleArg - The article to add to the search collection * @returns void * * @example * ```typescript * articleSearch.addArticle({ * title: 'Advanced TypeScript Features', * content: 'This article covers advanced TypeScript concepts...', * tags: ['typescript', 'advanced'], * author: 'Jane Smith', * timestamp: Date.now(), * featuredImageUrl: null, * url: 'https://example.com/advanced-typescript' * }); * ``` */ addArticle(articleArg: plugins.tsclass.content.IArticle): void; /** * Performs a weighted fuzzy search across all articles * * The search uses the following weighting: * - Title: 3x importance * - Tags: 2x importance * - Content: 1x importance * * @param searchStringArg - The search query string * @returns Array of articles matched with their relevance score and match details * * @example * ```typescript * // Search for articles about TypeScript * const results = await articleSearch.search('typescript'); * * // Access the first (most relevant) result * if (results.length > 0) { * console.log(results[0].item.title); * * // See where the match was found * console.log(results[0].matches); * } * ``` */ search(searchStringArg: string): Promise; }