brickcharts
Version:
A comprehensive library for managing Billboard and Last.FM charts with visualizations and data management
100 lines (99 loc) • 2.34 kB
TypeScript
import { ChartData, ChartEntry, ChartSource } from '../types';
export interface SearchQuery {
title?: string;
artist?: string;
album?: string;
chartType?: string;
source?: ChartSource;
dateRange?: {
start: Date;
end: Date;
};
rankRange?: {
min: number;
max: number;
};
weeksRange?: {
min: number;
max: number;
};
peakRange?: {
min: number;
max: number;
};
newEntriesOnly?: boolean;
fuzzy?: boolean;
limit?: number;
}
export interface SearchResult {
entry: ChartEntry;
chartData: ChartData;
score: number;
matches: SearchMatch[];
}
export interface SearchMatch {
field: 'title' | 'artist' | 'album';
value: string;
matchType: 'exact' | 'partial' | 'fuzzy';
confidence: number;
}
export interface SearchStats {
totalResults: number;
searchTime: number;
chartsSearched: number;
exactMatches: number;
partialMatches: number;
fuzzyMatches: number;
}
export declare class SearchEngine {
private searchIndex;
private chartDataCache;
/**
* Index chart data for faster searching
*/
indexChartData(chartData: ChartData[]): void;
/**
* Enhanced search with fuzzy matching and ranking
*/
search(query: SearchQuery): {
results: SearchResult[];
stats: SearchStats;
};
/**
* Quick search for autocomplete
*/
quickSearch(term: string, field?: 'title' | 'artist' | 'album', limit?: number): string[];
/**
* Search for similar entries
*/
findSimilar(entry: ChartEntry, limit?: number): SearchResult[];
/**
* Get trending searches (placeholder for future implementation)
*/
getTrendingSearches(): string[];
/**
* Clear search index
*/
clearIndex(): void;
/**
* Add entry to search index
*/
private addToIndex;
/**
* Get charts relevant to search query
*/
private getRelevantCharts;
/**
* Score an entry against search query
*/
private scoreEntry;
/**
* Match text with different strategies
*/
private matchText;
/**
* Calculate string similarity (Levenshtein distance based)
*/
private calculateSimilarity;
}
//# sourceMappingURL=SearchEngine.d.ts.map