// This definition is incomplete. It only includes the functionality that we
// use. For a complete reference, see http://elasticlunr.com/docs/index.html.
declare module "elasticlunr" {
    function elasticlunr(): elasticlunr.Index;

    namespace elasticlunr {
        export type Document = { [key: string]: string };
        export type Processor = (token: string) => string;

        export interface Index {
            pipeline: Pipeline;
            addField(name: string): void;
            setRef(name: string): void;
            saveDocument(save: boolean): void;
            addDoc(doc: Document): void;
            removeDoc(doc: Document): void;
            updateDoc(doc: Document): void;
            search(text: string, config?: any): Result[];
        }

        export interface Result {
            ref: string;
            score: number;
        }

        export function tokenizer(str: string): string[];

        export interface Pipeline {
            add(f: Processor): void;
            remove(f: Processor): void;
            reset(): void;
            run(tokens: string[]): string[];
        }

        export namespace Pipeline {
            export function registerFunction(f: Processor, label: string): void;
            export function getRegisteredFunction(label: string): Processor;
        }

        export namespace tokenizer {
            export function setSeperator(sep: RegExp): void;
        }
    }

    export = elasticlunr;
}
