export = elasticlunr; declare function elasticlunr( config?: (this: elasticlunr.Index, idx: elasticlunr.Index) => void, ): elasticlunr.Index; declare namespace elasticlunr { class Configuration { constructor(config: string, fields: Array); addAllFields2UserConfig(bool: Bool, expand: boolean, fields: Array): void; buildDefaultConfig(fields: Array): void; buildUserConfig(config: SearchConfig, fields: Array): void; get(): SearchConfig; reset(): void; } type DocumentReference = string | number; class DocumentStore { constructor(save?: boolean); addDoc(docRef: DocumentReference, doc: T): void; addFieldLength(docRef: DocumentReference, fieldName: keyof T, length: number): void; getDoc(docRef: DocumentReference): T; getFieldLength(docRef: DocumentReference, fieldName: keyof T): number; hasDoc(docRef: DocumentReference): boolean; isDocStored(): boolean; removeDoc(docRef: DocumentReference): void; toJSON(): SerialisedDocumentStore; updateFieldLength(docRef: DocumentReference, fieldName: keyof T, length: number): void; static load(serialisedData: SerialisedDocumentStore): DocumentStore; } type EventType = "add" | "update" | "remove"; type EventHandler = (...args: any[]) => void; class EventEmitter { constructor(); addListener(e1: EventType, fn: EventHandler): void; addListener(e1: EventType, e2: EventType, fn: EventHandler): void; addListener(e1: EventType, e2: EventType, e3: EventType, fn: EventHandler): void; emit(name: EventType, ...args: any[]): void; hasHandler(name: EventType): boolean; removeListener(name: EventType, fn: EventHandler): void; } interface SearchScores { [key: string]: number; } interface SearchResults { ref: string; score: number; } interface IndexTokens { [key: string]: string[]; } interface IndexDocuments { [key: string]: T; } type Bool = "OR" | "AND"; type FieldSearchConfig = { [K in keyof T]?: { bool?: Bool | undefined; boost?: number | undefined; }; }; interface SearchConfig { fields?: FieldSearchConfig | undefined; expand?: boolean | undefined; bool?: Bool; } interface SerialisedInvertedIndex { root: InvertedIndexNode; } interface SerialisedDocumentStore { docInfo: { [docRef: string]: { [field in keyof T]: number; }; }; docs: { [docRef: string]: T; }; } interface SerialisedIndexData { version: string; fields: Array; ref: keyof T; pipeline: SerialisedPipeline; documentStore: SerialisedDocumentStore; index: { [K in keyof T]?: InvertedIndexNode }; } class Index { constructor(); documentStore: DocumentStore; eventEmitter: EventEmitter; index: { [K in keyof T]?: InvertedIndex }; pipeline: Pipeline; addDoc(doc: T, emitEvent?: boolean): void; addField(fieldName: keyof T): Index; coordNorm(scores: SearchScores, docTokens: IndexTokens, n: number): SearchScores; fieldSearch(queryTokens: string[], fieldName: keyof T, config: FieldSearchConfig): SearchScores; fieldSearchStats(docTokens: IndexTokens, token: string, docs: IndexDocuments): void; getFields(): Array; idf(term: string, field: keyof T): number; mergeScores(accumScores: SearchScores | null, scores: SearchScores, op: "AND" | "OR"): SearchScores; off(name: EventType, fn: EventHandler): void; on(e1: EventType, fn: EventHandler): void; on(e1: EventType, e2: EventType, fn: EventHandler): void; on(e1: EventType, e2: EventType, e3: EventType, fn: EventHandler): void; removeDoc(doc: T, emitEvent?: boolean): void; removeDocByRef(docRef: DocumentReference, emitEvent?: boolean): void; saveDocument(save: boolean): Index; search(query: string, userConfig?: SearchConfig): SearchResults[]; setRef(refName: keyof T): Index; toJSON(): SerialisedIndexData; updateDoc(doc: T, emitEvent?: boolean): void; use(plugin: (...args: any[]) => any, ...args: any[]): void; static load(serialisedData: SerialisedIndexData): Index; } interface TokenInfo { ref: number | string; tf: number; } interface InvertedIndexCharNode { a?: InvertedIndexNode | undefined; b?: InvertedIndexNode | undefined; c?: InvertedIndexNode | undefined; d?: InvertedIndexNode | undefined; e?: InvertedIndexNode | undefined; f?: InvertedIndexNode | undefined; g?: InvertedIndexNode | undefined; h?: InvertedIndexNode | undefined; i?: InvertedIndexNode | undefined; j?: InvertedIndexNode | undefined; k?: InvertedIndexNode | undefined; l?: InvertedIndexNode | undefined; m?: InvertedIndexNode | undefined; n?: InvertedIndexNode | undefined; o?: InvertedIndexNode | undefined; p?: InvertedIndexNode | undefined; q?: InvertedIndexNode | undefined; r?: InvertedIndexNode | undefined; s?: InvertedIndexNode | undefined; t?: InvertedIndexNode | undefined; u?: InvertedIndexNode | undefined; v?: InvertedIndexNode | undefined; w?: InvertedIndexNode | undefined; x?: InvertedIndexNode | undefined; y?: InvertedIndexNode | undefined; z?: InvertedIndexNode | undefined; } interface InvertedIndexDocs { [key: string]: { tf?: number | undefined; }; } type InvertedIndexNode = InvertedIndexCharNode & { df: number; docs: InvertedIndexDocs; }; class InvertedIndex { constructor(); addToken(token: string, tokenInfo: TokenInfo, root?: InvertedIndexNode): void; expandToken(token: string, memo?: string[], root?: InvertedIndexNode): string[]; getDocFreq(token: string): number; getDocs(token: string): InvertedIndexDocs; getNode(token: string): InvertedIndexNode; getTermFrequency(token: string, docRef: string | number): number; hasToken(token: string): boolean; removeToken(token: string, ref: number | string): void; toJSON(): SerialisedInvertedIndex; static load(serialisedData: SerialisedInvertedIndex): InvertedIndex; } type SerialisedPipeline = string[]; // eslint-disable-next-line @typescript-eslint/no-invalid-void-type type PipelineFunction = (token: string, i: number, tokens: string[]) => string | undefined | null | void; class Pipeline { constructor(); add(...functions: PipelineFunction[]): void; after(existingFn: PipelineFunction, newFn: PipelineFunction): void; before(existingFn: PipelineFunction, newFn: PipelineFunction): void; get(): PipelineFunction[]; remove(fn: PipelineFunction): void; reset(): void; run(tokens: string[]): string[]; toJSON(): SerialisedPipeline; static getRegisteredFunction(label: string): PipelineFunction; static load(serialised: SerialisedPipeline): Pipeline; static registerFunction(fn: PipelineFunction, label: string): void; static warnIfFunctionNotRegistered(fn: PipelineFunction): void; } class SortedSet { constructor(); add(...args: any[]): void; clone(): SortedSet; forEach(fn: (element: T, index: number, collection: T[]) => void, ctx: {}): void; indexOf(elem: {}): number; intersect(otherSet: SortedSet): SortedSet; locationFor(elem: T): number; map(fn: (element: T, index: number, collection: T[]) => T, ctx?: {}): T[]; toArray(): T[]; toJSON(): T[]; union(otherSet: SortedSet): SortedSet; static load(serialisedData: T[]): SortedSet; } const defaultStopWords: { [key: string]: boolean; }; const version: string; function addStopWords(words: string[]): void; function clearStopWords(): void; function resetStopWords(): void; function stemmer(w: string): string; function stopWordFilter(token: string): string; function tokenizer(str?: string): string[]; function trimmer(token: string): string; namespace Pipeline { namespace registeredFunctions { function stemmer(w: string): string; function stopWordFilter(token: string): string; function trimmer(token: string): string; namespace stemmer { const label: string; } namespace stopWordFilter { const label: string; const stopWords: { [key: string]: boolean; }; } namespace trimmer { const label: string; } } } namespace stemmer { const label: string; } namespace stopWordFilter { const label: string; const stopWords: { [key: string]: boolean; }; } namespace tokenizer { const defaultSeperator: RegExp; const seperator: RegExp; function getSeperator(): RegExp; function resetSeperator(): void; function setSeperator(sep: RegExp): void; } namespace trimmer { const label: string; } namespace utils { function toString(obj: {}): string; function warn(message: string): void; } }