UNPKG

@orama/plugin-match-highlight

Version:

Orama plugin for search match highlighting

27 lines (24 loc) 1.41 kB
import { AnyOrama, Result, Results, RawData, TypedDocument, SearchParamsFullText, Language } from '@orama/orama'; interface Position { start: number; length: number; } type OramaWithHighlight<T extends AnyOrama> = T & { data: { positions: Record<string, Record<string, Record<string, Position[]>>>; }; }; type ResultWithPositions<ResultDocument> = Result<ResultDocument> & { positions: Record<string, Record<string, Position[]>>; }; type SearchResultWithHighlight<ResultDocument> = Omit<Results<ResultDocument>, 'hits'> & { hits: ResultWithPositions<ResultDocument>[]; }; type RawDataWithPositions = RawData & { positions: Record<string, Record<string, Record<string, Position[]>>>; }; declare function afterInsert<T extends AnyOrama>(orama: T, id: string): Promise<void>; declare function searchWithHighlight<T extends AnyOrama, ResultDocument = TypedDocument<T>>(orama: T, params: SearchParamsFullText<T, ResultDocument>, language?: Language): Promise<SearchResultWithHighlight<ResultDocument>>; declare function saveWithHighlight<T extends AnyOrama>(orama: T): RawDataWithPositions; declare function loadWithHighlight<T extends AnyOrama>(orama: T, raw: RawDataWithPositions): void; export { OramaWithHighlight, Position, RawDataWithPositions, ResultWithPositions, SearchResultWithHighlight, afterInsert, loadWithHighlight, saveWithHighlight, searchWithHighlight };